Generating a SSH Key Pair - uic-ric/uic-ric.github.io GitHub Wiki

Table of Contents

Introduction

SSH/SFTP servers can utilize private/public key pairs for authentication. With each key pair the private key should stored in a safe location and protected by a passphrase, if possible. The public key, on the other hand, is safe to distribute and share with other individuals. You can use our SSH Key Check page to check the format of your SSH public key and generate the MD5 and SHA256 fingerprints that can be used to quickly identify public keys.

macOS or Linux

1. Open a command line window. On macOS use the “Terminal” application (Go to "Applications", then "Utilities", and choose the "Terminal" application).

2. Execute the command “ssh-keygen”. Be sure to use a key size of at least 2048 bit. This is set using the “-b” argument. Key sizes should be powers of 2, i.e. 2048, 4098, 8192, etc. If you have an existing key pair and wish to generate a new one, use the “-f” to specify the output file. Recommended command:

 [user@server ~]$ ssh-keygen –b 2048

3. Follow the instructions to generate the key pair. It is recommended to set a key passphrase, when prompted, to encrypt your private key in order to prevent it from being used if stolen. You MUST remember this passphrase, as it is required to use the ssh key in the future. We recommend storing the key using the default name and location.

If we have requested you to send us your public key prior to a workshop, you are now done. Please copy/paste your public key and send it to us in an email. You can view your key in the Terminal with this command, and copy the text to the body of an email:

 [user@server ~]$ cat ~/.ssh/id_rsa.pub

4. If you need to add the public key to an authorized_keys file or send to a service for access, such as for SFTP access to the RRC Data Portal, use the contents of the “.pub” file created.

If you are using a recent version of MacOS or Linux, you should be able to copy your public key to a remote system using the “ssh-copy-id” command. When using the "ssh-copy-id" command specify your login ID and the remote server name in the same manner as if you were using the "ssh" command. For example.

  [user@server ~]$ ssh-copy-id <username>@<remote system>

Windows OS

These instructions assume that PuTTY is installed on your system. If not, you can obtain the installation package at this URL (https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)

1. Open the puttygen.exe application. The PuTTY tools are typically installed in C:\Program Files (x86)\PuTTY

2. From the puttygen dialog, ensure that the key size is at least 2048 bits and click Generate. Key sizes should be powers of 2, i.e. 2048, 4098, 8192, etc. Clicking Generate will start the processes of generating a new SSH key pair. Please follow the instructions on screen.

3. Once the key pair has been generated, you should see a screen shot similar to the following.
4. Save both the public and private key files for later usage by clicking the Save public key and Save private key. It is recommended to set a key passphrase (see above dialog) to encrypt your private key in order to prevent it from being used if stolen.

NOTE: You MUST remember this passphrase, as it is required to use the ssh key in the future.

If we have requested you to send us your public key prior to a workshop, you are now done. Please copy/paste your public key from Putty and send it to us in an email.

If you need to add the public key to an authorized_keys file or send to a service for access, such as for SFTP access to the RRC Data Portal, use the text in box titled Public key for pasting into OpenSSH authorized_keys file

Setting up WinSCP to use a keypair

1. In the Login dialog click the Advanced... button

2. In the Advanced Site Settings select Authentication under SSH

3. Select your private key using in the Authentication parameters section of the dialog

4. Click OK

⚠️ **GitHub.com Fallback** ⚠️