Saturday 15 September 2012

SSH : Passwordless - Linux/Windows


Public key: it's not actually a key, but you could think it as an lock. You could make lot of copies and distribute it where ever you wish like. You need to copy in ".ssh/authorized_keys" folder.

Private key: this is an actual key, that to be used to open a lock (public key). Your public key can be distributed any where, as long as your private key is not compromised. When you run "ssh-keygen" – it produces both private (id_rsa) & public( keys for usage.

Pass phrase - what exactly is this ?
Encrypting an private key using an another key i.e... Equivalent of putting the private key in a combo-lock safe which adds one more layer of protection. Incase of your private key falls into the wrong hands, the person should still know the password to use the private key.

You could use either rsa/dsa for encryption/decryption depending on your security.

Case 1: windows to Linux server.
For linux administrators that use windows for their desktop os, putty is a tool. This tutorial will help you save time administering your servers without having to login and provide username and password each time.

I am trying to create an ssh2-rsa passwordless authentication from windows to linux server.

Here are the steps to go on:
1.   Download your putty and puttygen.
2.   Open your puttygen, select ssh2-rsa, and click generate.
3.   Move your mouse around in the space to generate public key

4.   Save your private key and copy your public key
5.   Open your putty session:
              enter hostname or ip address.
              click connection -> data -> enter "root" for auto login username.
              in connections -> ssh -> browse to the private key (from step 4)
              save your session
6.   Log into the server, paste the public key in the below path and quit.
      [root@server ~]# vim .ssh/authorized_keys
7.  You must now be able to login to your server without password.

Case 2: Linux to Linux server
1. Create your public key in the server.
     [root@server ~]# ssh-keygen -t rsa
2. View your public key once it is generated.
     [root@server ~]# cat .ssh/
3. Copy your public key in the ".ssh/authorized_keys" file on the destination folder.

Once it is done, your passwordless authentication is successful.

No comments:

Post a Comment