是否可以使用 ssh 连接上传文件


Is it possible to upload files using ssh connection?

im 使用与服务器的 SSH 连接,我想知道是否有上传文件的命令,例如放在 SFTP 连接上。

include('Net/SSH2.php');
include('Crypt/RSA.php');
$key = new Crypt_RSA();
$key->loadKey(file_get_contents('/pathtokey.pem'));

$ssh = new Net_SSH2('ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com');
if (!$ssh->login('user', $key)) {
exit('Login Failed');
}

多谢

您可以使用SCP通过SSH发送文件

http://php.net/manual/en/function.ssh2-scp-send.php