How to Generate and Use SSH Private & Public Keys?

One effective way of securing SSH access to your cloud server is to use a public-private key pair. This means that a public key is placed on the server and the private key is placed on your local workstation. Using a key pair makes it impossible for someone to log in by using just a password, as long as you set up SSH to deny password-based authentication.

Generating keys


Use PuTTYgen to generate your public and private keys. Download PuTTYgen from the PuTTY download page. (PuTTYgen might have been installed previously with PuTTY or WinSCP.)

  1. Launch the program, and then click the Generate button. The program generates the keys for you.
  2. Enter a unique key passphrase in the Key passphrase and Confirm passphrase fields, or leave it empty in order not to use the passphrase.
  3. Save the public and private keys by clicking the Save public key and Save private key buttons. From the Public key for pasting into the OpenSSH authorized_keys file field at the top of the window, copy all the text (starting with ssh-rsa) to your clipboard by pressing Ctrl-C. You need this key available on your clipboard to paste either in the Client Area or directly into the authorized keys section on your Cloud Server.

Unix-like operating systems:

This applies to macOS, Linux and other unix-like OS. As an example, we will be using macOS during this part of the guide.

  1. First, you will need to access the Terminal. You can find it via Search.
  2. Enter the following command in the Terminal window:
    ssh-keygen -t rsa 
  3. Now you will have to choose a file path where your keys will be saved. You can specify a path:
    or you can simply press Enter and it will use the default path and file name, which is
    We recommend using the default one.
  4. At this point, it is possible to set up a password for your key pair. You can write in your desired password or you can press Enter to leave the field blank and not use a password.
  5. After the last step, your Private and Public keys will be generated in the specified directory.
  6. You can locate and open your keys to see them in a text format. The public key will have .pub extension and you will upload this key to your remote server. However, make sure not to share your private key with anyone.

Use the key pair

You can use the RSA key pair in the following ways.

Add a new public key to the list

In the Terminal, go to your server’s dashboard and then to the Security tab, where you will find your SSH Keys. Click Add Key. Enter the key label and then paste the entire public key into the Public key field. If you mark it as default, the current and all future machines will be assigned this key. Then click Yes. Go back to the Security tab and confirm that your key is listed in the SSH Key list.

Was this article helpful?

Still need help?

Heficed Slack Community

Get involved in Heficed Slack community. Get updates, ask questions, connect with peers.

Heficed Slack

Need support?

If you need any further help, don't hesitate to send a support request to our support team.