如何在 php 中调用 ssh2_exec 函数以在远程服务器中执行命令,而无需对我的服务器密码进行硬编码?
这是PHP手册参考:
<?php
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'myusername', 'mypasswordisvisibleforeveryone');
$stream = ssh2_exec($connection, '/usr/local/bin/php -i');
?>