简体   繁体   中英

Execute sript shell script with remote command from php

I try execute this script from my php but I retrieve error not permission to execute from hostkey invalid.

ssh myuser@hostname "mkdir /home/userhome/teste555"

My php

$message=shell_exec("/var/www/html/x.sh 2>&1");
  print_r($message);

return result:

Could not create directory '/var/www/.ssh'. Host key verification failed.

I have access to server, but my user executing command is www-data

It means that host key of the remote server was changed.

Edit ~/.ssh/known_hosts file to remove the host name or IP address of the remote server.

Or use the command to do this directly:

ssh-keygen -R hostname

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM