Generating SSH keys in Windows
Parent page: SSH
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
- Select 'Ed25519' (RSA 2048 bits and above is acceptable too).
- 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.
- Enter a passphrase for your key.
- Click the "Save private key" button and choose a meaningful file name (e.g. compute_canada.ppk).
Connecting with a key pair
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 upload it to CCDB as per instructions in SSH Keys Installing your key in the section "Using CCDB", STEP 3.
Alternatively, here is another way:
- 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_keyson the server you wish to connect to as the user
USERNAMEwith WinSCP or an editor launched from that server such as vim or nano.
- Ensure directory, file permissions are correct and have the correct owner as described in steps 2 and 3 of these instructions.
- Test the new key by connecting to the server as
USERNAMEusing 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
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.