如果我想连接到aws服务器,权限被拒绝

时间:2018-01-14 12:14:56

标签: amazon-web-services ubuntu ssh

我在AWS上的不同地区推出了两个Ubuntu免费层服务器。我将一台服务器ping到另一台服务器,但它显示一条连接超时的错误消息。请您尽快解决问题。

这是错误:

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/home/ubuntu/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Permission denied (publickey).


    172.31.94.158 | UNREACHABLE! => {
        "changed": false, 
        "msg": "Failed to connect to the host via ssh: ssh: connect to host 172.31.94.158 port 22: Connection timed out\r\n", 
        "unreachable": true
    }

我尝试了以下命令

1.ssh-copy-id ubuntu@172.31.94.158
2.sudo ansible webserver -m ping

1 个答案:

答案 0 :(得分:0)

最简单的方法是在连接到服务器的安全组上打开端口22,以便连接另一台服务器的公共IP。

如果它是简单的测试服务器,并且您希望在短时间内检查ssh连接,并且在测试完成后立即删除服务器。然后你可以公开打开ssh端口"高度不安全"