Normally, there's an ad running in this spot, but you're using an ad blocker. To help support our blog, which provides free tutorials for everybody, we just ask that you whitelist or follow us on facebook, twitter, or subscribe using the form to the leftabove. Thank you!

    Generating a New SSH Key

    Select Your OS:

    Whether you're setting up a local machine or a cloud-based server, setting up SSH keys is something you'll do time and time again. SSH authentication is more secure than plain text password authentication because the remote server will verify against the local server's private key. Essentially, you can whitelist the computers/servers that have access to the target machine.

    If you already have a remote server to connect to, you can skip the prerequisites. If not, the prerequisites will show you how to spin up a virtual machine that you can practice SSHing into.

    Generating the private and public SSH keys

    1. Open PuttyGen.
    2. Select SSH-2 RSA under Type of key to generate and click the Generate button.
    3. Move your mouse over the area below the progress bar to generate randomness.
    4. Type your passphrase in the Key passphrase field.
    5. Click Save private key to save the private key to your local machine. You will need this to SSH into remote machines.
    6. Right-click inside the text field labeled Public key for pasting into the OpenSSH authorized_keys file and choose Select All.
    7. Right click in the same field and left click Copy.
    1. Run the following commands on the local machine (your desktop/laptop's main operating system).
    2.     ssh-keygen -t rsa -C ""
    3. The following message will be output to the terminal, indicating that the new ssh key was created.
    4.     Generating public/private rsa key pair.
    5. Now answer the following prompts. The key's filename and passphrase are optional. We won't override the key or type in a passphrase, for training purposes. Unless you've indicated a path and filename, you'll find the key at the following location:
    6. The private key will be located in the same directory as the public key.

        Enter file in which to save the key (/home/user/.ssh/id_rsa):
        Enter passphrase (empty for no passphrase):
        Enter same passphrase again:

      The following SSH key details will now be output to your screen.

        Your identification has been saved in test.
        Your public key has been saved in
        The key fingerprint is:
        52:e6:74:09:89:96:13:80:c4:41:5f:a9:1f:14:cd:33 roblayton@local
        The key's randomart image is:
        +--[ RSA 2048]----+
        | ++o..+O..       |
        |  o. .B E. .     |
        |    .+ .+oo      |
        |    . .= .       |
        |     ...S        |
        |      ..         |
        |                 |
        |                 |
        |                 |
    7. Anytime you need to print the public key to the screen, run cat ~/.ssh/ in the shell.

    Did you like this tutorial? Help us pay for server costs by following us on Facebook, Twitter, and subscribing below, where you'll get post notifications, training webinar invites, and free bundles.