xtmci

PuTTY public key authentication

Sun May 3 6:35 pm EDT 2026

Key points

  • Generate a public and private key pair.
  • Register the public key on the server.
  • Log in to the server using the private key.

How to do it

Run puttygen.exe program from the Command Prompt or the File Explorer. (You can download the puttygen.exe file from the PuTTYgen homepage.)

Select RSA for the type of key. Click Generate. Move your mouse freely over the blank area to speed up the key generation process.

Select the newly generated public key with your mouse and copy it. Click Save private key to save your private key as a file with .ppk extension. Keep this file in a safe place.

Log in to your server. Create .ssh directory in your home directory and set desired permissions:

mkdir ~/.ssh
chmod 700 ~/.ssh

Go to .ssh directory. Create authorized_keys file and set the permissions:

cd ~/.ssh
touch authorized_keys
chmod 600 authorized_keys

Open the authorized_keys file:

vim authorized_keys

Paste the public key you've copied earlier into the file as a single line:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCmilaYkSS8uI14a22rNZVo2pJqlMuyNBE75q/tgYMWrcqjiV2Ve/HUE8aJOswO+Ytp3IYYyNT8IPs9D70tAZNhslx7o29pVGEcek+koGGYIc0m6ekvZucT+CdYGZ/H52dOAusCvRrxBmxyDHFraQlb0oATqW2Xsew5EZ65PpYA4moa9LrG16EsqDKTqXz3Ej1gooAlUUeGbU53YvsdSyX7zAXyBqZKCC5UqCwl1SlVmstbswDM+r7NjL6rGao6l6NitfBfYyrLG7OuV9UVxUA2g2IHbfsXppy/NV4xSuiLKDoynXUvF9mrpupILNsptbT3/JMnyljkHVGmZSFUNBkb rsa-key-19991231

Save and exit the file.

Now, you can login to your server through the public key authentication.

Open the Command Prompt and use putty.exe program. To specify your private key file, you can use -i switch as shown below:

putty.exe -i your_private_key.ppk user@domain.com