3

I created a key on my machine with ssh-keygen. I copied the key to remote machine using ssh-copy-id.

Tried to connect to remote machine but it asked me the password. Both machines are ubuntu (local 11.04, remote 8.04)

EDIT (Output with extra verbose)

Here is the verbose from ssh:

    OpenSSH_5.8p1 Debian-1ubuntu3, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /home/leandro/.ssh/config
debug1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to 192.168.1.217 [192.168.1.217] port 22.
debug1: Connection established.
debug3: Incorrect RSA1 identifier
debug3: Could not load "/home/leandro/.ssh/id_rsa" as a RSA1 public key
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /home/leandro/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/leandro/.ssh/id_rsa-cert type -1
debug1: identity file /home/leandro/.ssh/id_dsa type -1
debug1: identity file /home/leandro/.ssh/id_dsa-cert type -1
debug1: identity file /home/leandro/.ssh/id_ecdsa type -1
debug1: identity file /home/leandro/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.7p1 Debian-8ubuntu1
debug1: match: OpenSSH_4.7p1 Debian-8ubuntu1 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.8p1 Debian-1ubuntu3
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "192.168.1.217" from file "/home/leandro/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/leandro/.ssh/known_hosts:6
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: ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,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],ecdsa-sha2-nistp384-cert-v0[email protected],[email protected],[email protected],[email protected],ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,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-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],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-sha256,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,[email protected],hmac-ripemd160,[email protected],hmac-sha1-96,hmac-md5-96
debug2: kex_parse_kexinit: hmac-md5,hmac-sha1,[email protected],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: 132/256
debug2: bits set: 527/1024
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: RSA 72:d5:e9:a2:09:46:e5:f2:e9:65:39:56:ba:f8:bc:38
debug3: load_hostkeys: loading entries for host "192.168.1.217" from file "/home/leandro/.ssh/known_hosts"
debug3: load_hostkeys: found key type RSA in file /home/leandro/.ssh/known_hosts:6
debug3: load_hostkeys: loaded 1 keys
debug1: Host '192.168.1.217' is known and matches the RSA host key.
debug1: Found key in /home/leandro/.ssh/known_hosts:6
debug2: bits set: 555/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: /home/leandro/.ssh/id_rsa (0x21ef1040)
debug2: key: /home/leandro/.ssh/id_dsa ((nil))
debug2: key: /home/leandro/.ssh/id_ecdsa ((nil))
debug1: Authentications that can continue: publickey,password
debug3: start over, passed a different list publickey,password
debug3: preferred gssapi-keyex,gssapi-with-mic,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: /home/leandro/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/leandro/.ssh/id_dsa
debug3: no such identity: /home/leandro/.ssh/id_dsa
debug1: Trying private key: /home/leandro/.ssh/id_ecdsa
debug3: no such identity: /home/leandro/.ssh/id_ecdsa
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
[email protected]'s password: 

leandro@FiberWork72:~$ cd ~/.ssh/
leandro@FiberWork72:~/.ssh$ ls
config  id_rsa  id_rsa.pub  known_hosts  known_hosts.bkp  known_hosts.old

EDIT:

Ok. I notice something here. I was looking at the ~/.ssh/authorized_keys and realized that in the end of the key it's written this:

me@my_computer_name 

instead of:

me@my_computer_ip

I don't know if have something to do with it, but...

14
  • 3
    Can you double check the permissions on the foreign host? SSHd can be pretty picky. May 30, 2012 at 14:50
  • 1
    @utopiabound: I don't believe this to be a permissions issue. For one, ssh-copy-id takes care of that, and it's one of the best reasons to use it instead of the older manual method. For another, you see ssh trying to use the keys instead of skipping them, which means at least the client side perms are correct. May 30, 2012 at 15:04
  • @Rockskull: The user names are apparently different on both hosts. Did you say ssh-copy-id myuser@remotehost, or just ssh-copy-id remotehost? Check that a copy of ~/.ssh/id-rsa.pub on localhost exists in ~/.ssh/authorized_keys on remotehost. May 30, 2012 at 15:06
  • @WarrenYoung the client side perms are correct, yes, but the server side isn't seeing any of the keys as valid, so there's something going on.
    – Kevin
    May 30, 2012 at 15:06
  • Rockskull, did you remember to provide the correct username?
    – Kevin
    May 30, 2012 at 15:07

3 Answers 3

3

This tag wiki has good information about ssh and how to troubleshoot some basic problems.

My first guess would be to check the permissions on ~/.ssh and ensure it is not writable by any user other than you. You can read more on that here.

1
  • I tried permissions and, as @WarrenYoung commented, the ssh-copy-id takes care of that.
    – lcguida
    May 30, 2012 at 19:01
2

Did you name your key something different than id_rsa, id_dsa or id_ecdsa?

By default, ssh will only try with these key names. If you have chose another one, no panic, you can either specify the key name using -i or specify it once and for all in your ~ssh/config file.

Example with -i (perhaps you need to add the ~/.ssh/ before the key name, I can't recall):

ssh -i <your_priv_key_name> [email protected]

Example of ~/.ssh/config

Host 192.168.1.217
  IdentityFile ~/.ssh/<your_priv_key_name>
1
  • No I haven't name something different. I know I have this done right because I made the same thing with a ssh tunnel I configured in another machine, and it worked, no password required.
    – lcguida
    May 30, 2012 at 18:52
1

Assuming that "myuser" is a valid user on the remote system, the key needs to be placed in that users ~/.ssh/authorized_keys (if using the default configuration).

Check your sshd_config on the remote server to ensure what the authkey file should be, look for the line AuthorizedKeysFile.

1
  • 1
    Tried that. Didn't work.
    – lcguida
    May 30, 2012 at 19:00

You must log in to answer this question.

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