【发布时间】:2018-10-05 14:53:50
【问题描述】:
我想使用 PHP 通过 SFTP 传输文件。
远程服务器提供 IP、用户名和密码,包括带有密码的 PPK 文件。我可以使用 WinSCP 登录,但是在我的 php 脚本中我遇到了ssh2_auth_pubkey_file() 的问题
你能告诉我我应该如何处理给定的 PPK 文件吗? 我需要提供哪些公钥和私钥来进行身份验证?
非常感谢清晰的解释。谢谢!
代码:
$conn = ssh2_connect($host, $port, array('hostkey'=>'ssh-rsa'));
if(ssh2_auth_pubkey_file($conn,$username,$pub_key,$pri_key,$passphrase)){
echo "Public Key Authentication Successful\n";
}else{
die('Public Key Authentication Failed');
}
我使用的公钥来自 PuTTYgen。 将 PPK 转换为 PUB 文件。
【问题讨论】: