Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

When I run

ravbholua@ravbholua-Aspire-5315:~$ rlogin 109.202.101.166

it promps me for password as below:

ravbholua@ravbholua-Aspire-5315:~$ rlogin 109.202.101.166
ravbholua@109.202.101.166's password:

To make password free access, I created a file /etc/hosts.equiv in the remote machine (ravi.com) as below:

root@ravi:/etc# cat hosts.equiv
localhost
42.110.54.211
root@ravi:/etc#

But still whenever I run the above command to login to this remote machine, it asks for password.

Additionally, I also created .rhosts file in my same like-to-like account in remote machine in home dir. as below:

ravbholua@ravi:~$ cat .rhosts
localhost
42.110.54.211
ravbholua@ravi:~$

What may be the problem that I am not able to have password-free access.

One important point to be noted: To know what's my internet IP address is, I got from the below two sites (both gave the same IP address)

http://www.ipchicken.com/
http://whatismyip.org/

You may please refer to the below link where I had asked for the same query but couldn't get resolved. not-able-to-do-password-free-access-to-remote-machine


Edit: I ran:

ravbholua@ravbholua-Aspire-5315:~$ sudo scp ~/.ssh/id_rsa.pub rs:.ssh/authorized_keys

as without sudo, it messaged:permission denied. Then I tried both

sudo ssh rs

and

ssh rs 

Still I was prompted for password. I entered my remote server after entering password and found the file that was transferred in /root/.ssh as shown ahead.

root@ravi:~/.ssh# ls                             
authorized_keys known_hosts                                      
root@ravi:~/.ssh# 

Please note rs is an alias for my remote server.

share|improve this question
4  
What distribution are you using? Almost no one ships a real rlogin by default any longer because it is horribly insecure. OpenSSH sometimes provides an alias for ssh called rlogin which never even looks at .rhosts because that's part of the horrible insecurity. See the answer by @maxschlepzig for how to remote shell properly. If you have the option of installing an old-fashioned RFC1282 rlogind, don't, It's a Bad Idea. –  msw Sep 15 '13 at 11:39

1 Answer 1

You can also use ssh to configure password-less login to a remote computer.

It is just (on computer a):

$ ssh-keygen # use an empty password!
$ scp ~/.ssh/id_rsa.pub computer_b:.ssh/authorized_keys

That's it.

Now you can do a

$ ssh computer_b

without having to enter a password.

You can optionally configure things like:

  • host alias for computer_b, e.g. to be able to enter ssh alias
  • set public-key authentication as default for that host/alias
  • allow only public-key authentication (for the sshd on computer_b)

Unless you can't use ssh, it seems to be much more convenient to setup than rlogin.

Plus, ssh protects you against main-in-the-middle attacks and eavesdropping.

Troubleshooting

Make sure that the ~/.ssh has the right permissions (on both systems) - i.e. is only accessible by your user - otherwise ssh ignores it. That means only rwx------ for the directory and rw------- for the files. Use ls -l and ls -ld to verify this.

Make sure that the remote ~/.ssh/authorized_keys contains the correct public key. Verify via:

$ ssh computer_b cat '~/.ssh/authorized_keys' # remote
$ cat ~/.ssh/id_rsa.pub # local

If the setup does not work like this, perhaps you have to explicitly configure the client side, i.e. adding something like this to .ssh/config:

Host computer_b
Hostname some_hostname
User juser
PreferredAuthentications publickey # makes testing easier
IdentitiesOnly yes
IdentityFile ~/.ssh/id_rsa.pub

For diagnosing issues it is also useful to add -v to ssh call, e.g.:

$ ssh -v computer_b
share|improve this answer
    
Oh! it didn't work. –  Ravi Sep 15 '13 at 14:15
    
@Ravi, added some infos on troubleshooting ssh issues. –  maxschlepzig Sep 15 '13 at 15:31
    
Great it worked. Thanks! But one point: I tried it for root and not an ordinary user. Because for the ordinary user (user-name: ravbholua), the directory ~ravbholua/.ssh is owned by root. root@ravi:/home/ravbholua# ls -ld .ssh drwx------ 2 root root 4096 Sep 10 08:09 .ssh root@ravi:/home/ravbholua# Now for this to work for the user named 'ravbholua',how to proceed. Shall I make root to renounce the ownership to the user named ravbholua. Also what may be the reason that the .ssh directory under the user ravbholua has root as the owner –  Ravi Sep 17 '13 at 2:14
    
@ maxschlepzig Hi! Now ordinary user (ravbholua) is also enjoying password free login. root renounced the ownership of the .ssh directory to the user ravbholua and hence achieved what was required. Thanks a lot for your asssitance. Great!! –  Ravi Sep 17 '13 at 14:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.