doutuo3899 2015-12-09 22:28
浏览 73
已采纳

来自python脚本的SSH,由PHP后端代码触发

I am trying to call a python script from php (Using xamp).
The python script internally calls a shell script and the shell script has an ssh and scp command.
On executing the PHP back-end code using exec I observe the following errors in xamp log file.
The python script works fine through command line

Could not create directory '/sbin/.ssh'.^M
Failed to add the host to the list of known hosts          (/sbin/.ssh/known_hosts).^M
Permission denied, please try again.^M
Permission denied, please try again.^M
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).^M
Could not create directory '/sbin/.ssh'.^M
Host key verification failed.^M
  • 写回答

2条回答 默认 最新

  • dreamwind1985 2015-12-09 22:33
    关注

    Presumably, the python script is being run by a different user when it's called by PHP than when you run it by hand, which does not have appropriate permissions to do whatever actions the script is trying to perform. So you'll need to tweak permissions / user groups for the various things the script is going to be trying to do in order for it to run successfully.

    Looking at this question is probably a good starting point:

    How to check what user php is running as?

    Once you identify the user that is actually running the script, you can try running the script as that user and then fixing problems as they come up.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?