Generating SSH keys in Windows

From Alliance Doc
Revision as of 14:48, 29 September 2021 by Gauriaur (talk | contribs)
Jump to navigation Jump to search
Other languages:

Parent page: SSH

PuTTYgen pre key generation (Click for larger image)
PuTTYgen post key generation (Click for larger image)

If using PuTTY or MobaXTerm the process of generating a key is nearly the same with only minor differences. In MobaXTerm go to the Tools->MobaKeyGen (SSH key generator), and with PuTTY run the PuTTYGen executable both of these methods will result in displaying a very similar window which can be used to generate or load an existing key.

Generating a key pair[edit]

  1. Select 'Ed25519' (RSA 2048 bits and above is acceptable too).
  2. Click the "Generate" button. You will then be asked to move your mouse around to generate random data to be used to create the key.
  3. Enter a passphrase for your key.
  4. Click the "Save private key" button and choose a meaningful file name (e.g. compute_canada.ppk).

Connecting with a key pair[edit]

We encourage all users to leverage the new CCDB feature to upload their SSH public key. Grab the content from the text box under "Public key for pasting into OpenSSH authorized_keys" and see instructions in SSH Keys Installing your key in the section "Using CCDB".

Alternatively, here is another way:

  1. Add the public key from the text box under "Public key for pasting into OpenSSH authorized_keys", by copying and pasting it, as a single line to the end of the /home/USERNAME/.ssh/authorized_keys on the server you wish to connect to as the user USERNAME with WinSCP or an editor launched from that server such as vim or nano.
  2. Ensure directory, file permissions are correct and have the correct owner as described in steps 2 and 3 of these instructions.
  3. Test the new key by connecting to the server as USERNAME using ssh (see connecting with PuTTY using a key pair or connecting with MobaXTerm using a key pair).

Key generation and usage is demonstrated in this youtube video with PuTTY: Easily setup PuTTY SSH keys for passwordless logins using Pageant.

Converting an OpenStack key[edit]

When a key is created on OpenStack you obtain a key with a ".pem" extension. This key can be converted to a format used by PuTTY by clicking the "Load" button in PuTTYGen. Then select the "All Files (*.*)" filter and select your ".pem" file downloaded from OpenStack and click "Open". You should also add a "Key passphrase" at this point to use when accessing your private key and then click "Save private key".

This private key can be used with PuTTY to connect to a VM that OpenStack injects with the matching public key under the "Key Pairs" tab under the "Access & Security" tab when launching a new VM. You can read more about connecting using PuTTY or MobaXterm.