How to Generate SSH Keys

SSH access allows you to have ‘command-line access’ to the server that houses your account. This gives you a secure, remote connection to your server and account. The SSH program uses a password to connect, but it is easier and more secure to use SSH ‘keys’. These keys are a type of cryptographic challenge and response that have many advantages. Shown below are a few ways to generate SSH keys of your own.

NOTE: This guide is intended for using SSH with root access with a VPS or Dedicated Server. If you are trying to use SSH and are subscribed to a Reseller or Shared Hosting plan, you can follow the directions in our guide on How to SSH into your Shared/Reseller Server (or for macOS).

Operating System:

Windows with Powershell

While OpenSSH is included natively on Windows 10, you will need to use the Powershell terminal to access it:

  1. Open the Start menu and type Powershell.
  2. Select Powershell and click the Run as Administrator option.
  3. Continue to the Unix instructions below.

Windows with PuTTY

PuTTY is a popular 3rd party software for SSH. If you prefer to utilize this tool, you can follow these steps.

  1. Open the PuTTYgen application. NOTE: If you don’t have PuTTYgen, you can download it from the PuTTY Download Page.
  2. Select key type For ‘Type of key to generate‘, select RSA.
     
  3. Determine number of bits For ‘Number of bits in a generated key‘, select 4096.
     
  4. Determine number of bits Click Generate.
     
  5. Click on Generate button Move your mouse pointer around in the Key section until the progress bar is full.
     
  6. Optional: Type a comment into the Key comment section to help with identifying this SSH key pair.
     
  7. Type key phrase Recommended: Type a secure passphrase into the Key passphrase field, and again into the Confirm passphrase field.
     
  8. save keys Finally, click the Save public key, and also the Save private key buttons. Be sure to save both keys in your user’s .ssh directory inside their home directory. For instance:
    C:\Users\userna5\.ssh\id_rsa.pub
    C:\Users\userna5\.ssh\id_rsa.ppk
     

Unix

This applies to users with on Linux, macOS, BSD, and OpenSSH via Powershell on Windows.

  1. Open Terminal from your Application list.
  2. Type the following into the Terminal and then hit Enter: ssh-keygen -t rsa -b 4096
  3. Press Enter again when you see a prompt to “Enter file in which to save the key“.
  4. When prompted type a secure passphrase, and press Enter.
  5. When prompted type the secure passphrase again to confirm, and press Enter.

You should see the following successful message containing the details that pertain to your key that was generated:

userna5@localhost ~ $ ssh-keygen -t rsa -b 4096
Generating public/private rsa key pair.
Enter file in which to save the key (/home/userna5/.ssh/id_rsa):  Enter passphrase (empty for no passphrase):  
Enter same passphrase again:  
Your identification has been saved in /home/userna5/.ssh/id_rsa. 
Your public key has been saved in /home/userna5/.ssh/id_rsa.pub. 
The key fingerprint is: SHA256:PRxLu/LU6ZfFDve1sTIR0nK86NJVYRxRONCz0N5oy7U userna5@localhost The key's randomart image is:
 +---[RSA 4096]----+ 
 |            .+.+=| 
 |            . *+ | 
 |          o oo.*.| 
 |         + * ==.o|
 |        S * =o++.|
 |           = =+E=|
 |        . = + .**|
 |         = + oooo|
 |          o ..o  |
 +----[SHA256]-----+

 

Was this article helpful? Let us know!