I am using PHP to ssh into a main computer and run a command. My code is posted below but I'm stuck having the following issue:
When I run this command from the Ubuntu command line it works flawlessly. However when I try and run it via the web page I believe the ssh commands are not running. Not sure if I am running into issues with permissions, or if I am running into issues with my actually ssh command in php. Any help would be appreciated.
$cmd = "ssh name@ip 'echo hello'";
$var = shell_exec($cmd);
echo $var;
Rather than using shell_exec
(which may be disabled for security reasons), look into using libssh2
.
Reference : http://php.net/manual/en/book.ssh2.php
我的猜测是,运行Web服务器的用户的〜/ .ssh目录中没有您的私钥文件。
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.