0

I have a server that I regularly log in to. And I have to type my password every time. I'm trying to change this...

I've followed the tutorials to the letter. On the server, I used ssh-keygen to generate an id_rsa* file pair. I added the .pub to the authorized_keys, and checked the permissions on both the .ssh directory and the authorized_keys file. Then I copied the id files to my home computer, confirmed all permissions, and tested. It didn't work. I tried again by generating the keys on the client and pushing them to the server. That didn't work, either. I've gone back to generating the keys on the server, and am trying to figure out what is going wrong...

I ran "ssh -vvv" from the client and here is the output (sanitized):

OpenSSH_5.9p1, OpenSSL 0.9.8x 10 May 2012
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 53: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to SERVER [IP-ADDRESS] port 22.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/Users/USER/.ssh/id_rsa" as a RSA1 public key
debug1: identity file /Users/USER/.ssh/id_rsa type 1
debug1: identity file /Users/USER/.ssh/id_rsa-cert type -1
debug1: identity file /Users/USER/.ssh/id_dsa type -1
debug1: identity file /Users/USER/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "SERVER" from file "/Users/USER/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /Users/USER/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug3: order_hostkeyalgs: prefer hostkeyalgs: [email protected],[email protected],ssh-rsa
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: [email protected],[email protected],ssh-rsa,[email protected],[email protected],ssh-dss
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc,aes256-cbc,arcfour,[email protected]
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],hmac-sha2-256,hmac-sha2-256-96,hmac-sha2-512,hmac-sha2-512-96,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: none,[email protected],zlib
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: kex_parse_kexinit: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: kex_parse_kexinit: ssh-rsa,ssh-dss
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,arcfour128,arcfour256,arcfour,aes192-cbc,aes256-cbc,[email protected],aes128-ctr,aes192-ctr,aes256-ctr
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: none,[email protected]
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: 
debug2: kex_parse_kexinit: first_kex_follows 0 
debug2: kex_parse_kexinit: reserved 0 
debug2: mac_setup: found hmac-md5
debug1: kex: server->client aes128-ctr hmac-md5 none
debug2: mac_setup: found hmac-md5
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug2: dh_gen_key: priv key bits set: 131/256
debug2: bits set: 512/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX:XX
debug3: load_hostkeys: loading entries for host "SERVER" from file "/Users/USER/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /Users/USER/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug3: load_hostkeys: loading entries for host "IP-ADDRESS" from file "/Users/USER/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /Users/USER/.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug1: Host 'SERVER' is known and matches the RSA host key.
debug1: Found key in /Users/USER/.ssh/known_hosts:1
debug2: bits set: 508/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug2: key: /Users/USER/.ssh/id_rsa (0x7ffc1041d270)
debug2: key: /Users/USER/.ssh/id_dsa (0x0)
debug3: input_userauth_banner
...
debug1: Authentications that can continue: publickey,gssapi-with-mic,password,keyboard-interactive
debug3: start over, passed a different list publickey,gssapi-with-mic,password,keyboard-interactive
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/USER/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-with-mic,password,keyboard-interactive
debug1: Trying private key: /Users/USER/.ssh/id_dsa
debug3: no such identity: /Users/USER/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive
debug3: remaining preferred: password
debug3: authmethod_is_enabled keyboard-interactive
debug1: Next authentication method: keyboard-interactive
debug2: userauth_kbdint
debug2: we sent a keyboard-interactive packet, wait for reply
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1

I looked at the configuration on the server (/etc/ssh/sshd_config), and I don't see any obvious reasons why it wouldn't work. I compared it to the config on another server that I have successfully set this up with, and the only difference is that this server has a line "RSAAuthentication yes" and the server that actually works does not have that line.

In case it matters, the server is

Linux SERVER 2.6.18-194.17.4.el5 #1 SMP Wed Oct 20 13:03:08 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

and my client is a mac:

Darwin CLIENT 12.4.0 Darwin Kernel Version 12.4.0: Wed May  1 17:57:12 PDT 2013; root:xnu-2050.24.15~1/RELEASE_X86_64 x86_64

I can't actually look in the /var/log/secure log file on the server, as I am not an administrator on this box. So I'm feeling a little blind, and stumped.

Any thoughts on how to proceed?

3
  • 1
    Are you able to look at /etc/ssh/sshd_config on the server? It's possible that key based authentication is simply disabled.
    – replay
    Aug 27, 2013 at 14:22
  • The server rejected your public key. Check the logs on the server to find out why. Aug 27, 2013 at 14:46
  • debug3: no such identity: /Users/USER/.ssh/id_dsa Where's your private key?
    – dmourati
    Aug 27, 2013 at 18:27

3 Answers 3

1

Try using ssh-copy-id to copy the public key to the remote machine.

ssh-copy-id [-i [identity_file]] [user@]machine

I don't know if Mac has that tool, but it's on my RHEL machine. This should remove user configuration error from the authorized_keys configuration. Obviously, lock down the authorized_key settings (from, environment, etc) only AFTER the basic login works.

1

The process is to run ssh-keygen on the client, then paste the contents of .ssh/id_rsa.pub (on the client) into the file .ssh/authorized_keys on the server.

Effectively you make yourself a key, then tell the server that the key you have made (identified by the public half) is authorized to start an SSH session.

0

Your rsa key is offered here:

debug1: Offering RSA public key: /Users/USER/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-with-mic,password,keyboard-interactive
debug1: Trying private key: /Users/USER/.ssh/id_dsa

What does the server's log say? /var/log/secure or /var/log/auth.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .