Welcome to Srini's blog

Thursday, June 3, 2010

Secure Linux/UNIX access with PuTTY.

Everybody knows connect to a Linux system using putty password based auth, its very common approach to access linux system. However this password based auth is not secure, they are still open to brute-force attacks from anywhere on the internet.
So here I am explaining another auth method 'public key authtentication'.

Required tools : You need to download following files from Putty. These are simple '.exe' files and you need not to install. Just copy these exe files into one dir and you can run directly these files.
1. PuTTY.exe — Secure Shell client
2. PuTTYgen.exe — SSH public/private key generator.

Now follow the below steps

Step 1 : First you need to generate keypair(publickey and privatekey) using 'PuTTYgen.exe'(double click it), it will display one window to generate keys. The key pair is generated using a random number generator with the help of RSA/DSA algorithms. This will create a private key and a public key. The public key generated will be used for identity purpose. These both files will have the same file name and the public key is saved with “.pub” extension.

The Password/Passphrase you entered is used to encrypt your private key. If you left the password field blank, the key will not be encrypted. The contents of the 'comment' field are stored with your key, and displayed each time you are prompted for the key's password.

See the image for clarification


Give the passphrase and save the private key.

Step 2 : Upload the public key into targer server(the linux machine you want to connect thru putty). Login to the target server using password based auth and goto '.ssh/authorized_keys'(with in the user profile for e.g root user /root/.ssh), If the dir '.ssh' it not there then create dir and edit the file authorized_keys(using vi authorized_keys). copy the public key into clipbaord from and paste it into authorized_keys(see below image).



Step3 : Now connect to linux system usning 'PuTTy.exe'(double click it), It will prompt you one window to enter server details and private key.
see the image


It will prompt putty window(see below image) and will ask you login name.



Enter the login and passphrase

No comments:

Post a Comment