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
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.
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
Download and install Git Bash.
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
.Follow the on-screen instructions. Press enter to save the key in the default location.
Linux/Mac
Open a terminal.
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
.Follow the on-screen instructions. Press enter to save the key in the default location.
Identifying Private and Public Keys
To determine whether a key is private or public, you can inspect the content of the key.
A private key will typically begin with:
-----BEGIN RSA PRIVATE KEY-----
A public key will typically begin with:
ssh-rsa
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-----.
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
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 andserver_ip_address
with the IP address of your server.
Windows
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:
Download and install PuTTY and PuTTYgen from the official website.
Open PuTTYgen and click on
Load
. Select your private key (id_rsa
by default).Once loaded, click on
Save private key
to save it in PuTTY's PPK format.Open PuTTY, enter your server's IP address. In the
Auth
section underSSH
, browse and select your PPK private key.Click
Open
to connect to your server.
Using SSH Keys with Athorio's Cloud Solutions
Now that you have your SSH keys, you can use them with Athorio's cloud solutions for deploying machines securely.
Navigate to the Project Overview.
Go to the SSH-keys-section.
Here, you can add your public key along with a description.
By adding your SSH public key, you can ensure secure and password-less access to your deployed machines on Athorio's cloud platform.
Discover more in our tutorials
Browse through our selection of popular tutorials and discover new insights and tips.