简体   繁体   English

Bash脚本中的SSH命令未运行

[英]SSH command in Bash script not running

I have an SSH command in a bash script to connect and list a server's home files but when I run it from my PHP script I get no output. 我在bash脚本中有一个SSH命令来连接并列出服务器的主文件,但是当我从PHP脚本运行它时,没有任何输出。 I have setup an SSH key between my computer and the server. 我已经在计算机和服务器之间设置了SSH密钥。 Running the bash script in the terminal works but for some reason I can't get it to be called from the PHP script. 在终端中运行bash脚本是可行的,但是由于某种原因,我无法从PHP脚本中调用它。

Here is the bash script: 这是bash脚本:

#!/bin/bash
ssh user@location "ls"

And the PHP script which calls the script: 还有调用该脚本的PHP脚本:

<?php
chdir('/opt/lampp/htdocs');
echo shell_exec('./run');
?>

从php脚本“ Apache”运行时,只需检查“ Apache”用户在此文件夹中的执行权限即可。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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