Many a time, there is a need to access Linux server remotely from a Windows host. Of course we use putty (also MobaXterm for GUI) for that. But there are times when we need to access our Linux servers without needing to enter passwords. I had showed you how to setup password-less SSH for Linux. But that that is from Linux to Linux. Here we want to access Linux from Windows 🙂 Sounds interesting, right? 😉
Before I explain you we do this, I would like to describe the basics of SSH login. It is made possible by usage of encrypted key-pairs. One is private key & other is public key. Private key is what we store on the server/host we want to connect from (which is Windows machine here) & public key which is given out to any host we want to connect to (Linux here). It means any host that has public key can be accessed from any machine that has private key. Now that we have some understanding of SSH keys, lets jump to its implementation. Follow the steps as below.
Download puttygen from its official site on your Windows computer.
Run puttygen. It will display a window like this.
Then click “Generate” button to generate the key-pair. Keep moving your mouse so as to increase randomness in key. Once its done, it will display the public key in its window like below.
Click “Save private key” button & accept when it prompts to continue without passphrase. Its password-less anyway 😉 Save it to some safe location.
Now select the public key that is shown in the puttygen window & copy it.
Now open putty on your Windows computer & on the left side, you will see “SSH” under Connection. Expand it & you will see “Auth”. There you will see a “Browse” button on the right. Click it & locate your private key that you saved in 3rd step.
Now login to your Linux server (open a new putty window for this) using the user-name you want password-less SSH for. Go to .ssh directory & create a file
[shashank@vhedtdspfs02 ~]$ cd .ssh
[shashank@server .ssh]$ vi authorized_keys
Paste the copied public key (the one you copied from puttygen) in
authorized_keys file. Make sure only you can read this file.
chmod 700 it.
Now go back to putty window (already open in previous steps) & move to “Session”. In “Host Name or IP address” text-box, enter user@IP address or host-name & press enter. Remember to use the same user for which you created
You will be successfully logged-in using the SSH key pair 🙂
Using username "shashank". Authenticating with public key "rsa-key-20151028" Last login: Tue Oct 27 05:45:06 2015 from 10.16.66.196 [shashank@server ~]$
Hope this was easy & useful 🙂