[SOLVED] Ubuntu 16.04 SSH key authentication

krisla

New Member
Sep 16, 2016
4
0
1
33
Hello guys,

I've recently installed a container with template Ubuntu 16.04 and I have configured an SSH key authentication. The problem is that I'm still asked for password when I try to access it from the remote host. All permissions to /root/.ssh/authorized_keys are set correctly. Here is the output from debug:


debug1: sshd version OpenSSH_7.2, OpenSSL 1.0.2g 1 Mar 2016
debug1: private host key #0: ssh-rsa SHA256:qvGQTs5XG5SpMa2X8l8+W0avXOkqUO2GymmJyBpRAWE
debug1: private host key #1: ssh-dss SHA256:6D03T3pdZZfYRMtg5tN06H08MAKjwyAdcbAx5ulf9pc
debug1: private host key #2: ecdsa-sha2-nistp256 SHA256:UIV2sY2jvtn1zzmrVC6uBPJ73knfZ7Wm2PLwin5vREY
debug1: private host key #3: ssh-ed25519 SHA256:6n6Pt8Nd+NnWSDuaIwS+N6UVm9+GwvvVA6Jou/CQCeM
debug1: rexec_argv[0]='/usr/sbin/sshd'
debug1: rexec_argv[1]='-d'
debug1: Set /proc/self/oom_score_adj from 0 to -1000
debug1: Bind to port 22 on 0.0.0.0.
Server listening on 0.0.0.0 port 22.
debug1: Bind to port 22 on ::.
Server listening on :: port 22.
service ssh start
debug1: Server will not fork when running in debugging mode.
debug1: rexec start in 5 out 5 newsock 5 pipe -1 sock 8
debug1: inetd sockets after dupping: 3, 3
Connection from 217.16.11.100 port 59550 on 217.16.3.37 port 22
debug1: Client protocol version 2.0; client software version OpenSSH_6.6.1
debug1: match: OpenSSH_6.6.1 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: permanently_set_uid: 109/65534 [preauth]
debug1: list_hostkey_types: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519 [preauth]
debug1: SSH2_MSG_KEXINIT sent [preauth]
debug1: SSH2_MSG_KEXINIT received [preauth]
debug1: kex: algorithm: curve25519-sha256@libssh.org [preauth]
debug1: kex: host key algorithm: ecdsa-sha2-nistp256 [preauth]
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha1-etm@openssh.com compression: none [preauth]
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha1-etm@openssh.com compression: none [preauth]
debug1: expecting SSH2_MSG_KEX_ECDH_INIT [preauth]
debug1: rekey after 4294967296 blocks [preauth]
debug1: SSH2_MSG_NEWKEYS sent [preauth]
debug1: expecting SSH2_MSG_NEWKEYS [preauth]
debug1: rekey after 4294967296 blocks [preauth]
debug1: SSH2_MSG_NEWKEYS received [preauth]
debug1: KEX done [preauth]
debug1: userauth-request for user root service ssh-connection method none [preauth]
debug1: attempt 0 failures 0 [preauth]
debug1: PAM: initializing for "root"
debug1: PAM: setting PAM_RHOST to "217.16.11.100"
debug1: PAM: setting PAM_TTY to "ssh"
debug1: userauth-request for user root service ssh-connection method publickey [preauth]
debug1: attempt 1 failures 0 [preauth]
debug1: userauth_pubkey: test whether pkalg/pkblob are acceptable for RSA SHA256:Zxwz217RuODw6vu1iNs/PmPOn5B2Ws24pfwcUqRzmAQ [preauth]
debug1: temporarily_use_uid: 0/0 (e=0/0)
debug1: trying public key file /root/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK
Authentication tried for root with correct key but not from a permitted host (host=217.16.11.100, ip=217.16.11.100).
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 0/0 (e=0/0)
debug1: trying public key file /root/.ssh/authorized_keys2
debug1: fd 4 clearing O_NONBLOCK
Authentication tried for root with correct key but not from a permitted host (host=217.16.11.100, ip=217.16.11.100).
debug1: restore_uid: 0/0
Failed publickey for root from 217.16.11.100 port 59550 ssh2: RSA SHA256:Zxwz217RuODw6vu1iNs/PmPOn5B2Ws24pfwcUqRzmAQ
debug1: userauth-request for user root service ssh-connection method publickey [preauth]
debug1: attempt 2 failures 1 [preauth]
debug1: userauth_pubkey: test whether pkalg/pkblob are acceptable for DSA SHA256:uaZTcfWTQiqYF2mHvsIpXhuvsXtjVqcpG3QLRnhV4AM [preauth]
debug1: temporarily_use_uid: 0/0 (e=0/0)
debug1: trying public key file /root/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 0/0 (e=0/0)
debug1: trying public key file /root/.ssh/authorized_keys2
debug1: fd 4 clearing O_NONBLOCK
debug1: restore_uid: 0/0
Failed publickey for root from 217.16.11.100 port 59550 ssh2: DSA SHA256:uaZTcfWTQiqYF2mHvsIpXhuvsXtjVqcpG3QLRnhV4AM

Would appreciate any advice.

Kind regards,
 
"Authentication tried for root with correct key but not from a permitted host (host=217.16.11.100, ip=217.16.11.100)."

you need to whitelist your host.
 
Thank you for your reply,

I have found how to solve this, had to move the from= line from authorized_keys to the bottom of the file and it worked.

Regards,