← ServerPilot Docs

How to Generate an SSH Key

Before you can use SSH public key authentication, you need to generate an SSH key pair. A key pair is a set of related keys, one public key and one private key. You'll never share the private key with anyone and you won't put your private key on your server. Your public key, on the other hand, is safe to share with anyone and will be placed on your server when you enable SSH public key authentication.

You should generate your key pair on your laptop, not on your server. All Mac and Linux systems include a command called ssh-keygen that will generate a new key pair.

If you're using Windows, you can generate the keys on your server. Just remember to copy your keys to your laptop and delete your private key from the server after you've generated it.

To generate an SSH key pair, run the command ssh-keygen.

ssh-keygen

You'll be prompted to choose the location to store the keys. The default location is good unless you already have a key. Press Enter to choose the default location.

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/yourname/.ssh/id_rsa):

Next, you'll be asked to choose a password. Using a password means a password will be required for you to use the private key. It's best practice to use a password on your private key.

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

After you choose a password, your public and private keys will be generated. There will be two different files created. The file named id_rsa is your private key. The file named id_rsa.pub is your public key.

Your identification has been saved in /Users/yourname/.ssh/id_rsa.
Your public key has been saved in /Users/yourname/.ssh/id_rsa.pub.

You'll also be shown a fingerprint and "visual fingerprint" of your key. You do not need to save this information.

The key fingerprint is:
d7:21:c7:d6:b8:3a:29:29:11:ae:6f:79:bc:67:63:53 yourname@laptop1
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|           . o   |
|      .   . * .  |
|     . .   = o   |
|      o S . o    |
|     . . o oE    |
|    . .oo +.     |
|     .o.o.*.     |
|     ....= o     |
+-----------------+
Last updated: July 17, 2023

Launch your first site in 5 minutes