5

I tried everything mentioned in this solution Why am I still getting a password prompt with ssh with public key authentication?, but still getting prompt for password.

My local log:

ssh -vvv srvFlink@remoteHost

debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
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: /home/srvFlink/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: /home/srvFlink/.ssh/id_dsa
debug3: no such identity: /home/srvFlink/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/srvFlink/.ssh/id_ecdsa
debug3: no such identity: /home/srvFlink/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/srvFlink/.ssh/id_ed25519
debug3: no such identity: /home/srvFlink/.ssh/id_ed25519: No such file or directory
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
srvFlink@remoteHost's password:

Remote machine file permission:

drwx------.  2 srvFlink srvFlink   58 Aug 18 04:46 .ssh

-rw-------. 1 srvFlink srvFlink 1679 Aug 18 04:41 id_rsa
-rw-r--r--. 1 srvFlink srvFlink  406 Aug 18 04:41 id_rsa.pub
-rw-rw-r--. 1 srvFlink srvFlink  406 Aug 18 04:45 authorized_keys
drwx------. 2 srvFlink srvFlink   58 Aug 18 04:46 .
drwx------. 4 srvFlink srvFlink 4096 Aug 18 05:14 ..

In /etc/selinux/config file I have.

SELINUX=permissive
SELINUXTYPE=targeted

Content of id_rsa.pub of my local machine is there in the Remote machine ~/.ssh/authorized_keys

Content of /etc/ssh/sshd_config is same in both of the machine.

What might be the issue?

EDIT

Looks like file permission issue:

$ journalctl _COMM=sshd
Aug 18 06:54:53 localhost sshd[8891]: error: Could not load host key: /etc/ssh/ssh_host_dsa_key
Aug 18 06:54:53 localhost sshd[8891]: Authentication refused: bad ownership or modes for file /home/srvFlink/.ssh/authorized_keys
Aug 18 06:54:56 localhost sshd[8891]: Connection closed by remotehost [preauth]
Zeeshan
  • 153

3 Answers3

5
-rw-rw-r--. 1 srvFlink srvFlink  406 Aug 18 04:45 authorized_keys

should be

-rw-r--r--. 1 srvFlink srvFlink  406 Aug 18 04:45 authorized_keys

as noted in the post you linked in your question, where the accepted answer reads in part "Your home directory ~, your ~/.ssh directory and the ~/.ssh/authorized_keys file on the remote machine must be writable only by you"

You also don't post the permissions on your home directory in the question; ensure that those are also not group- or other-writable.

user4556274
  • 8,995
  • 2
  • 33
  • 37
0

I had the exact same problem on two servers: a Linux running Debian stretch and on a NAS (Synology DS715)

it turned out that in both cases, the home directory permissions on the server were wrong

the auth.log on the server was very helpful

Authentication refused: bad ownership or modes for directory /home/cyril

on the Linux, it had the write/group bit on (drwxrwxr--x), so I had to remove at least the write on group (chmod g-w ~/) and then it worked

on the Synology, for whatever reason, there was a sticky bit

drwx--x--x+ 4 toto users 4096 Jan 6 12:11 /var/services/homes/toto

I had to change it with

chmod -t ~/

and I could then connect without a password

-2

The debuglog clearly shows that your ssh client only tries id_rsa, id_dsa, id_ecdsa and id_ed25519 files, not id_rsa.pub.

Ipor Sircer
  • 14,546
  • 1
  • 27
  • 39