Connect to a Server Using an SSH Key

In this post I will describe how to connect to remote server using SSH Key instead of password.

Prerequisites

Connect via PuTTY

putty, Connect to a Server Using an SSH Key

PuTTY is the most popular SSH client for Windows users, and it is available for all versions of Windows. Download and install it, and PuTTY is ready to use.

1. Enter the username and IP address (root@11.22.33.44, for example) in the Host Name field. If your server has a domain name, you may use that in place of the IP address.

2. Select SSH as the connection type.

putty ssh login, Connect to a Server Using an SSH Key

3. In the left-hand menu, select Connection -> SSH -> Auth.

4. Click the Browse... button and choose your PuTTY private key file with the .ppk extension.

5. Click Open to connect to your server. When finished, end your session with CTRL + D.

Connect via OpenSSH Client

Linux and macOS typically have SSH clients pre-installed, you can verify whether your workstation has an SSH client installed by running the following command:

$ ssh -V

If your workstation has an SSH client installed, initiate an SSH connection, substitutue your username and IP for the example. If your SSH Key is in the default location ~/.ssh/id_rsa :

$ ssh root@11.22.33.44

If your SSH Key is in a different location, use -i parameter to identify SSH Key location:

$ ssh -i /path/to/id_rsa root@11.22.33.44

If you have a passphrase for protecting your private key, enter the passphrase and you are now connect to remote server successfully. When finished, end your session with CTRL + D.