尝试使用 .pem 文件、PHP 和 phpseclib 连接到 Amazon EC2 实例。
我已经尝试了此帖子中提到的方法: ssh access to ec2 from php, 但是我一直收到“Error 111. Connection refused in…”的错误提示。
当我使用 ssh 和相同的 .pem 文件从自己的机器连接时,没有出现任何错误。
这是我正在使用的原始帖子中的代码:
我已经尝试了此帖子中提到的方法: ssh access to ec2 from php, 但是我一直收到“Error 111. Connection refused in…”的错误提示。
当我使用 ssh 和相同的 .pem 文件从自己的机器连接时,没有出现任何错误。
这是我正在使用的原始帖子中的代码:
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');
}