-   Linux - Software (
-   -   ssh prompts for password even though public and private keys have been generated (

kaplan71 05-07-2008 05:01 PM

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:


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:


$ ssh user@remotehost “cat >> ~/.ssh/authorized_keys” < ~/.ssh/
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.

acid_kewpie 05-07-2008 05:04 PM

the usual suspect is the remote .ssh folder not having rights of 600, as it implicitly undermines the security logic.

kaplan71 05-07-2008 05:10 PM

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.

acid_kewpie 05-07-2008 05:13 PM

OK, so let's check the output of the ssh client with a couple of extra -v's in the command.

acid_kewpie 05-07-2008 05:17 PM

you might also like a tool like ssh-copy-id which should ensure a key is copied to a remote server correctly.

kaplan71 05-07-2008 05:19 PM

Hi there --

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


{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_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.

kaplan71 05-07-2008 05:57 PM

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?

All times are GMT -5. The time now is 07:44 AM.