Generating Secure Shell (SSH) Keys

Last modified by Administrator on Tue, 09/13/2022, 11:48 AM
Page Rating
0 Votes

A public-private key pair (SSH Key Pair) is generated at a user’s local workstation for a secure remote communication to a server. Both the private key and public key comprise the encrypted identity of the user. The public key is sent and registered to a server.

As part of its best practices, COARE implements SSH protocol to ensure secure connection and easier login to COARE. To comply with this best practice and to ensure the security of COARE’s network, the COARE users are required to generate their SSH keys in using COARE or accessing their servers.

Generating SSH Keys on Windows

The following section details the process on generating SSH keys on Windows OS:

For Windows

  1. Download and install PuTTY Gen.
  2. Run the application.
  3. Under the Parameters section, make sure that the type of key is set to RSA and the number of bits should be 2048 for security purposes. Then click Generate.

    Note: Move your cursor while generating keys.


  4. Once you’ve generated the keys, save both the public and private Key by clicking Save public key and Save private key.

    Note: Passphrase is optional. (For added security – two factor authentication)


Command Prompt (for Windows 10 only)

  1. Open Command Prompt or Windows PowerShell.
  2. Issue the command: ssh-keygen


  3. To view public key, navigate to C:\Users\<username>/.ssh/ (see image below) or execute this command in the command prompt: more C:\Users\<username>/.ssh/


Generating SSH Keys on Mac or Linux

The following process details the process on generating SSH keys on Mac or Linux OS:

  1. Open Terminal.
  2. Issue the command: ssh-keygen


    • Default Location of your key pair.
       - Mac: /Users/username/.ssh/
       - Linux: /home/username/.ssh/
    • Passphrase is optional. (For added security – two factor authentication).


  3.  To view your public key, run this command: cat <public_key-path>

Note to Mac users:

Make sure to check if you are using sudo or user when generating keys.
For usual errors like: Permission Denied: Invalid Keys, users tend to forget that they generated their keys with sudo, but tried logging in without sudo (and vice versa).

For example:

#When generating keys sudo ssh-keygen  
#When logging inssh user@host  
It should be like this:  
#When generating keyssudo ssh-keygenorssh-keygen
#When logging insudo ssh user@hostorssh user@host

Download the SSH Key Generation Infographics

For Windows

COARE SSH Key Generation.png

For Windows 10

COARE SSH Key Generation Windows 10.png

For Mac and Linux

COARE SSH Key Generation Mac and Linux.png