Skip to content
xYnta
Go to websitexynta.com
Search
EN

Generating and using an SSH key (Windows, macOS and Linux)

Updated on

With an SSH key you log in via SSH without a password. You create a key pair: the private part stays on your own computer, the public part goes on your hosting package or Managed VPS.

Generating a key in Windows

  1. Install PuTTY

    Download PuTTY and install it. PuTTYgen comes with it.

  2. Open PuTTYgen

    Search the Start menu for PuTTYgen and open it.

  3. Choose the type of key

    At the bottom, under Type of key to generate, choose RSA.

  4. Generate the key

    Click Generate and move your mouse over the window until the progress bar is full.

  5. Choose a password for the key

    Enter a password of your choice under Key passphrase and Confirm passphrase.

  6. Save the private part

    Click Save private key and choose a file name. This file stays on your computer.

  7. Copy the public part

    Right-click in the field Public key for pasting into OpenSSH authorized_keys file, choose Select All and then Copy.

Using a key in Windows

  1. Open PuTTY

    Search the Start menu for PuTTY and open it.

  2. Open the key settings

    On the left, under Connection, click the plus sign next to SSH, then the plus sign next to Auth, and then Credentials.

  3. Choose your private key

    Under Private key file for authentication, click Browse and choose the file you saved when generating the key.

PuTTY now uses the key when you start an SSH session. Then, on the left under Session, enter the server name under Host Name and the port of your package under Port; you can read which these are at the bottom of this article.

Generating a key in macOS or Linux

  1. Open the Terminal

    On macOS, search for Terminal with Spotlight (the magnifying glass at the top right). On Linux, open your distribution's terminal.

  2. Start generating

    Type this command and press Enter:

    ssh-keygen -t rsa
  3. Choose the storage location

    Press Enter to use the default location.

  4. Choose a password for the key

    Enter a password (passphrase) and confirm it. It is not required, but strongly recommended.

  5. Show the public part

    Type this command and press Enter:

    cat ~/.ssh/id_rsa.pub

    You now see the public part of the key. That is what you put on your package.

Related articles