This tutorial details the steps to establish SSH authentication for connecting to a Linux machine from a Windows machine.
We assume that programs PuTTY
and PuTTYgen
are installed on the Windows machine.
- Generate a pair of SSH keys. If you already have them on the Linux machine, you can skip this step. Log in to a Linux machine and generate an SSH key pair named
id_rsa
byssh-keygen -t rsa -f id_rsa -C yourname
Replace
yourname
by any comment you want. This will produce a public key fileid_rsa.pub
and a private key fileid_rsa
. The public key needs to be in the~/.ssh/authorized_keys
file on any Linux machine you want to connect. -
Now we want to put the private key on the Windows machine so we can use it to connect to the Linux machine. You can use
WinSCP
or any other program to transfer this file to your Windows machine, or simply copy the content ofid_rsa
and paste to a text file on Windows. Let’s assume the private key file on Windows machine is still namedid_rsa
. -
Unfortunately the private key format used by
PuTTY
is different from that of Linux. We use thePuTTYgen
program to convert it to an appropriate format forPuTTY
. OpenPuTTYgen
, go to menuConversions
->Import Key
, and select theid_rsa
file. Click theSave private key
button to save it as sayid_rsa_putty.ppk
. This is the private key filePuTTY
will use. -
Open
PuTTY
-
enter Host Name (or IP address)
-
From
Connection
->Data
, enter your username on the Linux machine toAuto-login username
. -
From
Connection
->SSH
->Auth
, load theid_rsa_putty.ppk
file toPrivate key file for authentication
. -
From
Session
, provide a session name toSaved Sessions
and clickSave
. -
Now each time double-clicking the saved session will connect to the Linux machine via SSH key.
-