Xman Blog Inside

Saturday, September 09, 2006

Setup Passwordless SSH

It's convenient to setup passwordless SSH in a closed environment. Connecting to remote hosts becomes handy. Passwordless SSH Setup Step-by-Step:
1. Generate RSA public and private keys.
xman@sai ~ $ ssh-keygen -t ssh-rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/xman/.ssh/id_rsa):
Created directory '/home/xman/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/xman/.ssh/id_rsa.
Your public key has been saved in /home/xman/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xxcommand prompt PS for root:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx xman@sai

You have to enter empty passphrase, trading off security for the convenient connecting to remote hosts.

2. Append the content of the generated public key, id_rsa.pub, into the file $HOME/.ssh/authorized_keys at the remote host. The folder .ssh and the file authorized_keys at remote host must not allow group, or other access, in particular, set the permissions of .ssh to 700 and authorized_keys to 600.

Now you can simply "ssh remotehost" without the need to type password. :) The first time you connect to remote host using ssh:
xman@sai ~ $ ssh remotehost
The authenticity of host 'remotehost (192.168.1.100)' can't be established.
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'remotehost' (RSA) to the list of known hosts.
Last login: Sat Sep 9 23:50:33 2006 from localhost
xman@remotehost ~ $

Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home