Recover instance access after losing the private key

If you have lost the private key used to connect to your cloud instance, you will not be able to log in using SSH.

You may still be able to recover access if password login is configured on the instance.


  • Create a new pair

    Before attempting recovery, create a new SSH key pair that you will use to access the instance.

    The private key will remain on your computer, and the public key must be added to the instance.

    You can create a key pair in one of the following ways:

    1. 1
      Generate a key pair in your terminal, then import the public key.
      Generate an SSH key pair in your terminal
    2. 2
      Create a key pair in the Cloud dashboard and download the private key file.
      Create and manage key pairs





  • Recover access using the instance console

    This method only works  if password login is enabled on the instance.

    This may be the case if:

    • You set a password during instance creation using custom scripts
    • You configured a password for a user account after creating the instance.

     

    Step 1: log in to the instance console

    1. 1
      Navigate to Compute > Instances.
    2. 2
      Click the instance name.
    3. 3
      Open the Console tab.
    4. 4
      Log in using the username and password configured on the instance.

     

    Step 2: Add a new SSH key

    1. 1
      Navigate to the SSH directory.

    mkdir -p ~/.ssh

    cd ~/.ssh

    1. 2
      Edit the authorized_keys file.

    nano authorized_keys

    1. 3
      Paste your new public key into the file.
      Example format:

    ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC...

    1. 4
      Save the file and exit the editor.

     

    Step 3: Set the correct permissions

    Ensure the SSH directory and key file permissions are secure.

    chmod 700 ~/.ssh

    chmod 600 ~/.ssh/authorized_keys

     

    Step 4: Connect using the new key

    You can now connect to your instance using your new private key.

    Follow the steps to connect to cloud instances via SSH.





  • If console login is not possible

    If the instance only allows SSH key authentication and no password login is configured, access cannot be recovered.

    In this case you will need to:

    • Create a new instance
    • Restore data from backups or snapshots



What happens next

Take a look at our other articles and guides on the xneelo Cloud dashboard.
To avoid losing access in the future follow the best practices to manage private keys.