8

I am trying passwordless SSH in CentOS7 installed in VMWare. I followed steps from this link, but facing issue while using ssh. Below is the log:

[root@osboxes ~]# ssh root@localhost
root@localhost's password: 
Last login: Wed Sep 21 16:02:39 2016 from localhost.localdomain
[root@osboxes ~]# ssh -v root@localhost
OpenSSH_6.4, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /root/.ssh/config
debug1: /root/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 51: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type 1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.4
debug1: match: OpenSSH_6.4 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 1b:08:56:1a:03:c6:e9:1d:dd:bf:19:02:72:c0:1b:0f
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:2
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Unspecified GSS failure.  Minor code may provide more information


debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /root/.ssh/id_dsa
debug1: Trying private key: /root/.ssh/id_ecdsa
debug1: Next authentication method: password
root@localhost's password:

Also, The permissions on the files

  • ls -lZd ~ dr-xr-x---
  • ls -lZd ~/.ssh drwx------
  • ls -lZd ~/.ssh/authorized_keys -rw-------
Shitalb1
  • 103
  • 1
    What are the permissions on the files? ls -lZd ~ ~/.ssh ~/.ssh/authorized_keys? – Jakuje Sep 21 '16 at 19:40
  • @Jakuje ls -lZd ~ dr-xr-x--- ls -lZd ~/.ssh drwx------ ls -lZd ~/.ssh/authorized_keys -rw------- – Shitalb1 Sep 26 '16 at 17:18
  • 1
    please, edit the question with this information. It is not readable in the form. – Jakuje Sep 26 '16 at 17:52
  • @Jakuje Edited... – Shitalb1 Sep 27 '16 at 15:00
  • @Jakuje any other suggestion.. – Shitalb1 Oct 19 '16 at 15:34
  • 1
    You didn't list the owner and group of the files, which should be in the output and which matters. Also the log level is more helpful with -vvv – Jakuje Oct 20 '16 at 07:10
  • you can try debugging sshd, when your ssh client does not give you enough information. it helped me alot: https://unix.stackexchange.com/questions/36540/why-am-i-still-getting-a-password-prompt-with-ssh-with-public-key-authentication/55481#55481 – syss May 03 '18 at 08:32

2 Answers2

7

Your answer for CentOS 7 lies with SELinux:

restorecon -Rv ~/.ssh
0

In my case password less login was not working because of my home directory permissions because I changed the default permissions. Finally, here is what worked for me. my home directory permissions are

/home/username

drwxr----x. 18 username     groupname  4096 May 11 11:52 username

/home/username/.ssh

268823097 drwx------   2 username groupname     29 May 11 11:53 .ssh

/home/username/.ssh/authorized_keys

-rw-r----- 1 username groupname 402 May 11 11:53 authorized_keys
drmaa
  • 177