Solved

cannot rsh to linux using public key

Posted on 2012-04-04
5
580 Views
Last Modified: 2012-06-27
I'm reposting this because apparently my problem is not solved.

I have 2 linux computers. I am trying to ssh from one to the other w/o passwords. I can ssh from computer A to computer C, but not from A to B. I can't see where the difference is. On computer A,  I ran ssh-keygen which created ~/.ssh/id_rsa.pub.

I copied the contents of that id_rsa.pub file. Then, logged into computer B and appended the contents of A's id_rsa.pub to B's ~/.ssh/authorized_keys. I did the same with computer C.

When ssh'ing from A to C I get logged in, no password prompt. When ssh'ing from A to B it prompts me for a password. What am I doing wrong?
0
Comment
Question by:jmarkfoley
5 Comments
 
LVL 6

Expert Comment

by:torakeshb
ID: 37809660
There is no way.  I think you could have copied the wrong key file to server B..

"When ssh'ing from A to B it prompts me for a password." --> Are you able to get it when you give the password.
0
 
LVL 3

Expert Comment

by:gnemi
ID: 37809696
The public key goes to the server receiving the connection. The private key stays on the client.

The public key needs to be pasted into authorized_keys on the server. Private keys should be in the .ssh folder of the user you are connecting with.
0
 
LVL 12

Accepted Solution

by:
larsrohr earned 400 total points
ID: 37809780
So far, it seems you've taken the right steps.
A common issue is that of file permissions.  ssh won't honor your authorized_keys file if permissions on it or on ~/.ssh are too loose.  So a good place to start is with:
 chmod 700 ~/.ssh
 chmod 600 ~/.ssh/authorized_keys

It could also be that the sshd_config on B is different, not allowing public key authorization.  This isn't very likely, I'd say, but it may be worth comparing sshd_config on B versus C (often this is at /etc/ssh/sshd_config).

For a bit more clarity on the problem, assuming the above doesn't help, please try ssh'ing verbosely.  The output may be illuminating, if you can share it here.
 ssh -vvv username@Bmachine
0
 
LVL 2

Assisted Solution

by:bandris
bandris earned 100 total points
ID: 37810737
The most likely problem is the ownership or mode on
1. authorized_keys file or
2. .ssh directory

If you use ssh-copy-id to put you public key on remote computers you will not mess up the rights accidentally.
0
 
LVL 1

Author Closing Comment

by:jmarkfoley
ID: 37812275
Changing the permissions on the authorized_keys worked! I can't believe that didn't occur to me, but it was late. Bandris, great tip on the ssh-copy-id program. I didn't even know it existed.
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Secure Shell (SSH) is a network protocol for secure data communication, mainly used to administer remote Unix / Linux servers via command line. But it also allows the user to open a secure tunnel between a client and a server where he can send any k…
BIND is the most widely used Name Server. A Name Server is the one that translates a site name to it's IP address. There is a new bug in BIND (https://kb.isc.org/article/AA-01272), affecting all versions of BIND 9 from BIND 9.1.0 (inclusive) thro…
Viewers will learn how to properly install and use Secure Shell (SSH) to work on projects or homework remotely. Download Secure Shell: Follow basic installation instructions: Open Secure Shell and use "Quick Connect" to enter credentials includi…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now