Understanding and Creating SSH Keys

Understanding SSH Keys

SSH (Secure Shell) keys are a pair of cryptographic keys that are used for authenticating a client to a server without the need for a password. They are more secure than password-based authentication and are commonly used for remote server access, Git repositories, and more.

Private Key vs Public Key

  1. Private Key: This is a secret key that must be kept private. It resides on the client side (i.e., your computer). If someone gets access to your private key, they can access any system that uses this key for authentication.

  2. Public Key: This is the key you share with the world (e.g., you add it to the remote server). It can only be used to verify a signature, not to create one. When you try to connect to a server, the server will use the public key to create a challenge that can only be answered with the private key.

Creating SSH Keys

Windows

  1. Download and install Git Bash.

  2. Open Git Bash and enter the following command:

    ssh-keygen -t rsa -b 4096

    Expected Result:

    You'll be prompted to select a location to save your keys. By default, they are saved in /c/Users/yourusername/.ssh/id_rsa and /c/Users/yourusername/.ssh/id_rsa.pub.

  3. Follow the on-screen instructions. Press enter to save the key in the default location.

Linux/Mac

  1. Open a terminal.

  2. Enter the following command:

    ssh-keygen -t rsa -b 4096

    Expected Result:

    You'll be prompted to select a location to save your keys. By default, they are saved in ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub.

  3. Follow the on-screen instructions. Press enter to save the key in the default location.

Identifying Private and Public Keys

  1. To determine whether a key is private or public, you can inspect the content of the key.

  2. A private key will typically begin with:

    -----BEGIN RSA PRIVATE KEY-----

  3. A public key will typically begin with:

    ssh-rsa

  4. For example, to view the content of your private key:

    cat ~/.ssh/id_rsa

    Expected Result:

    You should see content starting with -----BEGIN RSA PRIVATE KEY-----.

  5. To view the content of your public key:

    cat ~/.ssh/id_rsa.pub

    Expected Result:

    You should see content starting with ssh-rsa followed by a long string.

Connecting to Servers Using SSH Keys

Linux/Mac

  1. To connect to a server using your SSH key:

    ssh -i ~/.ssh/id_rsa rio@server_ip_address

    Replace username with your server's username and server_ip_address with the IP address of your server.

Windows

  1. For Windows users, PuTTY is a popular SSH client, but it requires a different format for the private key. You'll need to convert your key using PuTTYgen:

  2. Download and install PuTTY and PuTTYgen from the official website.

  3. Open PuTTYgen and click on Load. Select your private key (id_rsa by default).

  4. Once loaded, click on Save private key to save it in PuTTY's PPK format.

  5. Open PuTTY, enter your server's IP address. In the Auth section under SSH, browse and select your PPK private key.

  6. Click Open to connect to your server.

Using SSH Keys with Athorio's Cloud Solutions

  1. Now that you have your SSH keys, you can use them with Athorio's cloud solutions for deploying machines securely.

  2. Navigate to the Project Overview.

  3. Go to the SSH-keys-section.

  4. Here, you can add your public key along with a description.

  5. By adding your SSH public key, you can ensure secure and password-less access to your deployed machines on Athorio's cloud platform.

Athorio Cloud SSH Key Section