Manage private SSH keys

Private SSH keys are used to securely connect to your cloud instances.

When you connect to an instance via SSH, your SSH client uses the private key to prove that you are authorised to access the instance.

This article explains how to safely store, create, and manage private key files when using SSH with xneelo Cloud.

Learn more about key pairs in xneelo Cloud.


  • Create a private key file


    In some scenarios you may need to manually create a private key file.

    For example, when a key pair is generated during instance creation, the private key is only displayed once for you to copy and save.

    You must store this key in a file before you can use it to connect via SSH.

    Steps

    1. 1
      Open a text editor on your computer.
    2. 2
      Paste the contents of the private key you just created into the text editor.
    3. 3
      Provide a name for the file with a .pem extension and ensure you select the type as All Files. For example: private-key.pem
    4. 4
      Save the file to a secure location on your computer.
    5. 5
      If you are using macOS or Linux you need to run the following command to use your saved private key:

    Open a terminal window on your computer.

    Type in the following command:

    chmod 600 /path/privatekeyname.pem

    /path/privatekey.pem is the location of the private key file





  • Set permissions on a private key file

    SSH requires private key files to have restricted permissions.

    The file must only be readable by the current user. If permissions are too open, SSH will refuse to use the key.

    Steps

    On Linux:

    1. 1
      Open a terminal window on your computer.
    2. 2
      Run the following command in your terminal:
    chmod 400 privatekeyname.pem

    On Windows:

    1. 1
      Open File Explorer and right-click on the .pem file.
    2. 2
      Select Properties > Security tab and choose Advanced.
    3. 3
      Choose Disable inheritance.
    4. 4
      Remove access to all users except for the current user.





  • Storing private key files

    Private key files should always be stored securely.
    Follow these guidelines when storing private keys:

    • Store the key in a secure location
    • Do not share your private key
    • Do not upload private keys to public repositories
    • Store backups in a secure password manager or encrypted storage





  • Losing private key files

    It is important not to lose your private key.

    If you lose access to your private key, you will not be able to connect to the instance using SSH.

    In some cases, you may be able to recover access to the instance.

    See how to recover instance access after losing the private key

    Best practices for managing SSH keys

    To avoid losing access to your instances:

    • Keep secure backups of important private keys
    • Create multiple SSH keys for administrators
    • Create additional user accounts with their own keys
    • Store keys in a password manager or encrypted storage



    Assist Note

    You can use your private keys to connect to your cloud instances.