LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 05-07-2008, 04:01 PM   #1
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Rep: Reputation: 39
ssh prompts for password even though public and private keys have been generated


Hi there --

I am trying to get a particular user account to be able to connect via ssh to another system by using rsa public and private keys.

The first thing I did was run the following command as the user in question, and made sure to have a null password:

Quote:
ssh-keygen -t rsa c
The public and private keys were created in the appropriate directory.

The next step I did was to run the command shown below to copy the public key of the user to the remote system:

Quote:
$ ssh user@remotehost “cat >> ~/.ssh/authorized_keys” < ~/.ssh/id_rsa.pub
After that was done, I connected to the remote system as the user, but I was still prompted for a password. It should be noted that the root account has a similar setup between the two machines, and it can connect using this method without a problem.

What do I need to do to correct this? Thanks.
 
Old 05-07-2008, 04:04 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
the usual suspect is the remote .ssh folder not having rights of 600, as it implicitly undermines the security logic.
 
Old 05-07-2008, 04:10 PM   #3
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hi there --

Thanks for your reply. I changed the settings of the remote .ssh folder to 600, and then restarted the remote system's ssh server. Unfortunately, that did not help matters.
 
Old 05-07-2008, 04:13 PM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
OK, so let's check the output of the ssh client with a couple of extra -v's in the command.
 
Old 05-07-2008, 04:17 PM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
you might also like a tool like ssh-copy-id which should ensure a key is copied to a remote server correctly.
 
Old 05-07-2008, 04:19 PM   #6
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hi there --

Here is the output that is generated when connecting in verbose mode:

Quote:
{localhost}[1] ssh -v sdc@<remote ip>
OpenSSH_4.2p1, OpenSSL 0.9.7f 22 Mar 2005
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to <remote ip> [<remote ip>] port 22.
debug1: Connection established.
debug1: identity file /export/home/sdc/.ssh/id_rsa type 1
debug1: identity file /export/home/sdc/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.2
debug1: match: OpenSSH_4.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.2
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-md5 none
debug1: kex: client->server aes128-cbc hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '<remote ip>' is known and matches the RSA host key.
debug1: Found key in /export/home/sdc/.ssh/known_hosts:3
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Next authentication method: gssapi-with-mic
debug1: An invalid name was supplied
Unknown code krb5 243

debug1: An invalid name was supplied
Unknown code krb5 243

debug1: Next authentication method: publickey
debug1: Offering public key: /export/home/sdc/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-with-mic,password
debug1: Trying private key: /export/home/sdc/.ssh/id_dsa
debug1: Next authentication method: password
sdc@<remote ip>'s password:
The Unknown code errors also occur with the root account, but it successfully connects to the remote host.
 
Old 05-07-2008, 04:57 PM   #7
kaplan71
Member
 
Registered: Nov 2003
Posts: 809

Original Poster
Rep: Reputation: 39
Hi there --

I used the ssh-copy-id utility to see if that would help. I deleted the original .ssh directory on the remote system to allow the creation of a new one. I ran the command as the user in question on the local system, and it did appear to create the directory on the remote system. One thing I did notice: the permissions were set to 700 as opposed to 600.

I first connected with the permissions left as they were, and I was prompted for a password. I then changed the permissions to 600, and connected once more, but was still prompted for the password.

One other item of note: when the permissions on the .ssh directory were set to 600, the user in question could NOT change, or cd, into it even though the user is the owner of the directory. Only root could get into it.

Your thoughts?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ssh public/private keys lord_darkhelmet Linux - Newbie 8 10-29-2005 03:14 PM
SSH public / private keys problem guideweb Linux - Software 7 08-27-2005 09:49 PM
SSH public/private key authentication with GnuPG keys? thinksincode Linux - Security 1 02-25-2005 02:33 PM
How to delete public & private keys for SSH? TrulyTessa Linux - Security 2 11-18-2004 12:27 PM
Help with SSH and public/private keys stodge Linux - Security 5 05-14-2003 01:22 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:50 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration