Scenario. The alice user logs in to the msk-web-01 server (centos7.2, selinux is enabled) using his ssh key and wants to launch the git pull command in the folder /www/mysite.ru/htdocs/ (owner of the folder - apache user).
To do this, write a small batch file:
#!/bin/sh #see http://ru.stackoverflow.com/questions/548545/ for details sudo setfacl -m apache:x $(dirname "$SSH_AUTH_SOCK") sudo setfacl -m apache:rwx "$SSH_AUTH_SOCK" cd /www/mysite.ru/htdocs/ pwd sudo su -s /bin/sh apache -c "/usr/bin/git pull" .... And it works ... giving out numerous warnings:
/www/site1.ru/htdocs Could not create directory '/usr/share/httpd/.ssh'. Failed to add the ECDSA host key for IP address '1.2.3.4' to the list of known hosts (/usr/share/httpd/.ssh/known_ho). Already up-to-date. /www/site2.ru/htdocs Could not create directory '/usr/share/httpd/.ssh'. Failed to add the ECDSA host key for IP address '1.2.3.4' to the list of known hosts (/usr/share/httpd/.ssh/known_ho). Already up-to-date.
The task is to get rid of these unnecessary records, achieving a clear conclusion by adding records to the global known_hosts.
You can get the desired effect by creating /usr/share/httpd/.ssh/known_hosts with the line CheckHostIP no :
/www/site1.ru/htdocs Already up-to-date. /www/site2.ru/htdocs Already up-to-date. /www/site3.ru/htdocs Already up-to-date.
Of course, this method is not considered as a solution to the problem, as well as other workarounds such as "completely disable the check" (say, once or twice )
PS Keys saved in one of two ways, first:
ssh-keyscan -t rsa,dsa git.mycomany.ru >> /etc/ssh/ssh_known_hosts second:
ssh-keyscan git.mycomany.ru >> /etc/ssh/ssh_known_hosts The difference is not particularly great: in the first case, Failed to add the RSA host, in the second case - Failed to add the ECDSA host key.
And even so with grief:
ssh-keyscan git.mycomany.ru,1.2.3.4 >> /etc/ssh/ssh_known_hosts
/usr/share/httpdis the user's home directory? ($ grep /usr/share/httpd /etc/passwd) - aleksandr barakin