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