Solved

cannot rsh to linux using public key

Posted on 2012-04-04
5
577 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

Complete Microsoft Windows PC® & Mac Backup

Backup and recovery solutions to protect all your PCs & Mac– on-premises or in remote locations. Acronis backs up entire PC or Mac with patented reliable disk imaging technology and you will be able to restore workstations to a new, dissimilar hardware in minutes.

Join & Write a Comment

Hello EE, Today we will learn how to send all your network traffic through Tor which is useful to get around censorship and being tracked all together to a certain degree. This article assumes you will be using Linux, have a minimal knowledge of …
When it comes to security, there are always trade-offs between security and convenience/ease of administration. This article examines some of the main pros and cons of using key authentication vs password authentication for hosting an SFTP server.
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

757 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

18 Experts available now in Live!

Get 1:1 Help Now