This question already has an answer here:

Today I have setup 3 servers (4 including the server sending the SSH commands) with a public SSH key so I can automate some scripts

It works on the 2 first systems but not on the third.. SSH still prompt for the password when sending a SSH command

Generate SSH public/private key on local server

root@local # ssh-keygen -t rsa
file > /var/.ssh_keys/id_rsa
passphrase > (empty)
root@local # ln -s /var/.ssh_keys/id_rsa /root/.ssh/id_rsa

Append key to remote hosts from local server

root@local # cat /var/.ssh_keys/id_rsa.pub | ssh root@host 'path="/var/.ssh_remote_key" && mkdir -p $path && cat >> $path/authorized_keys && ln -s $path/authorized_keys /root/.ssh/authorized_keys'

Local server

# uname -a
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u3 (2015-08-04) x86_64 GNU/Linux

# sshd -V
OpenSSH_6.7p1 Debian-5, OpenSSL 1.0.1k 8 Jan 2015

Remote servers (working)

# uname -a
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 GNU/Linux

# sshd -V
OpenSSH_6.7p1 Debian-5+deb8u3, OpenSSL 1.0.1t  3 May 2016

Remote server (still prompting for password)

# uname -a
Linux 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt25-2 (2016-04-08) x86_64 GNU/Linux

# sshd -V
OpenSSH_6.7p1 Debian-5+deb8u2, OpenSSL 1.0.1k 8 Jan 2015

CHMOD /root/.ssh = 0700
CHMOD /root/.ssh/authorized_keys = 0644

marked as duplicate by Gilles ssh Apr 23 '17 at 22:12

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

up vote 4 down vote accepted

Since the two remote servers share similar version of Unix/OpenSSH, the problem might be in the permission of the files in the .ssh folder.

Please confirm that:

  • .ssh directory permissions is not write-able to group/other (e.g 700 (drwx------) or 755 (drwxr-xr-x)
  • public key (.pub file) and authorized_keys are 644 (-rw-r--r--)
  • private key (id_rsa) is 600 (-rw-------)

If you are trying to login as root to the remote server, you should confirm also that /etc/ssh/sshd_config contains PermitRootLogin yes or PermitRootLogin without-password.

  • 1
    PasswordAuthentication yes was commented out.. Uncommenting the line didn't help either.. But after I deleted the symlink and moved authorized_keys directly into /root/.ssh it works :) thanks – clarkk Apr 23 '17 at 15:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.