Create public SSH keys

SSH keys are much safer than passwords and are considered best practice.


Secure Shell (SSH) uses encryption to secure the connection between a client and a server. In this guide, we'll show how to create SSH keys to log in to a server more securely.

SSH key authentication is more secure than passwords because the private key is never shared with anyone else. It’s also more convenient with SSH keys, since you don’t have to type your password each time you log in to your server.

When you generate SSH keys, two key files are created: a private key and a public key.

The private key is named id_ed25519. This key should be treated like a password and must never be disclosed.

The public key is named id_ed25519.pub. You can share this with others. This is also the part you place on servers you want to be able to log into using your private key.

After you have created your key pair, copy the contents of the .pub file (the public key) and place it on the remote server in the file .ssh/authorized_keys within your home directory.

Create SSH keys

The procedure for creating SSH keys is pretty similar across systems. However, there are some differences. Here, we'll cover macOS/Linux, Windows using OpenSSH, and Windows using WSL (Windows Subsystem for Linux).

Open a terminal and run:

Command
ssh-keygen -a 100 -t ed25519 -f ~/.ssh/id_ed25519

Choose a strong passphrase and press Enter to continue. You can skip this step, but we recommend setting a passphrase to protect your private key. Note that you will need to enter the passphrase twice. After confirming the passphrase, the system generates a key pair:

Output and prompts. Prompts are highlighted.
Generating public/private ed25519 key pair.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_ed25519.
Your public key has been saved in /home/user/.ssh/id_ed25519.pub.
The key fingerprint is:
SHA256:51yQPILlrqdxLQTe7VRxmdxVnCdozD19At2wsHBm/H4 [email protected]
The key's randomart image is:
+--[ED25519 256]--+
|        . .+B*oO*|
|       + . **=XoB|
|      o o =.o..+o|
|     . + o +  .  |
|      . S + ..   |
|       o B .  . E|
|      o + =    . |
|       = .       |
|      .          |
+----[SHA256]-----+

Type cat ~/.ssh/id_ed25519.pub in the terminal to display your public key.

Congratulations

Now you have your public SSH key, which you can add directly when you create a server on our KVM or VMware platform in Glesys Cloud.

Last updated

Was this helpful?