# Creating SSH keys with PuTTYgen Attach:puttygen.gif Attach:puttygen1.mp4 Attach:puttygen2.mp4 Attach:puttygen3.mp4 Attach:puttygen4.mp4 Attach:puttygen-cc.webm Attach:puttygen-cc.mp4 Attach:puttygen-cc.gif ## Generate Public/Private Key For additional security, you can use a public/private key pair to login. If you disable [password authentication](/sshd/disablepassword), your sshd setup will be more secure. # In the parameters field at the bottom, select the type of key to generate. This guide uses Ed25519. # Click `Generate`\\ Attach:puttygen-random.png # **Optional**: In `Key passphrase`, provide a passphrase and write it down securely. Type the passphrase again in `Confirm passphrase`. **WARNING**: If you use a passphrase, the key becomes worthless if you forget the passphrase! # Click `Save public key`. Give it a name like `publickey.pub`. This key can be shared with anyone. # Click `Save private key`. Give it a name like `privatekey.ppk`. Keep the private key safe; **never** share this key! **Optional**: To export this key for another ssh client, click on `Conversions` in the menu at top, then click `Export OpenSSH key`. Give it a name like `private.key`. You have now generated your public and private key! ## Adding the Public Key # Connect with PuTTY using a password as described at top. # Edit `~/.ssh/authorized_keys`:\\ Attach:putty-editauthorized.png # Select the public key from PuTTyGen, from the field `Public key for pasting into OpenSSH authorized keys file`. Type `ctrl+c` to copy.\\ Attach:putty-copyauthorized.png # Paste the key into `~/.ssh/authorized_keys` by pressing `Shift+[Ins]`. # Alternatively, you can get the public key from the .ppk you created earlier. Open it with Notepad. It should look like this: ---- BEGIN SSH2 PUBLIC KEY ---- Comment: "ed25519-key-20210809" AAAAC3NzaC1lZDI1NTE5AAAAINCB6GpCoQPG4byfLwqHyA2SMyTV7RjfVw+bqO3h fTDF ---- END SSH2 PUBLIC KEY ---- Ignore the comment lines, copying only the key; join the lines together, and add `ssh-ed25519` in front: ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINCB6GpCoQPG4byfLwqHyA2SMyTV7RjfVw+bqO3hfTDF ## Logging in with Private Key # Open PuTTY # Go to `Connection > SSH > Auth` # In `Private key file for authentication`, click `Browse`, and load your private key (**hint**: it ends in .ppk). # Click `Session` and fill in `Hostname` as described in the [PuTTY connect guide](/PuTTY/Connect). Then, click `Open`. # If you used a passphrase for the key, type it in.\\ Attach:putty-keypassphrase.png