Pages

Showing posts with label password. Show all posts
Showing posts with label password. Show all posts

Sunday, May 22, 2011

Configuring RSH without Password

Tried on RHEL and Oracle Linux:

[1] Install rsh-server*.rpm from the Linux distribution for your system or using yum.

[2] Add the following to /etc/securetty:
rsh
rexec
rlogin

[3] Edit the rsh, rexec, and rlogin files in /etc/xinetd.d/ and change value of disable from yes to no

[4] /etc/init/d/xinetd restart

[5] Add list of hosts to /etc/hosts as:


[6] Add the hosts to ~/.rhosts as:


[7] chmod 600 ~/.rhosts
Also, ensure .rhosts is owned by the right user:group. Otherwise use chown as well.

[8] Repeat steps 1 to 7 on all hosts

Now, you should be able to rsh among the hosts on which you have setup rsh-server correctly.


SSH without Password

In order to ssh from Host1 to Host2 without password, the following needs to be done:

user1@Host1:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user1/.ssh/id_rsa):
Created directory '/home/user1/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/user1/.ssh/id_rsa.
Your public key has been saved in /home/user1/.ssh/id_rsa.pub.

If ~/.ssh doesn't exist on Host2 as user2, create one:

user2@Host2:~> mkdir -p .ssh
user2@Host2:~> chmod 700 .ssh

Append user1's public key to authorized_keys and authorized_keys2 in user2@Host2:.ssh/:

user1@Host1:~> cat .ssh/id_rsa.pub | ssh user2@Host2 'cat >> .ssh/authorized_keys'
user1@Host1:~> cat .ssh/id_rsa.pub | ssh user2@Host2 'cat >> .ssh/authorized_keys2'

user2@Host2:~> chmod 640 .ssh

Now ssh from user1@Host1 to user2@Host2 should be possible without password:
user1@Host1:~> ssh user2@Host2\

Avoid Host Verification

ssh -o "StrictHostKeyChecking no" user@host

Debugging

Set LogLevel to DEBUG in /etc/ssh/sshd_config
/etc/init.d/sshd restart
Then try to ssh, debug messages will be logged to /var/log/secure
PS: Once you have resolved the issue remember to switch back LogLevel to INFO and again restart sshd.