Amazon Linux AMI ec2实例权限被拒绝(公钥)

时间:2016-04-13 10:07:38

标签: linux amazon-web-services ssh amazon-ec2 public-key

我在AWS中遇到一个实例的问题。

问题如下:

该实例是Amazon Linux AMI,包含Tomcat 6 Server并且还启用了SFTP连接。

我们可以通过ssh连接而没有任何问题,但突然间没有任何技术干预我们就无法连接ssh了。 Tomcat仍然可用,sftp连接仍然可用。

此问题有时已经发生,现在更频繁地发生,AWS论坛中的帖子也没有解决任何问题。

ssh痕迹是:

OpenSSH_7.1p2, OpenSSL 1.0.1g 7 Apr 2014
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file xxxxxxxxxx.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file xxxxxxxxxx.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to xxx.xxx.xxx.xxx:22 as 'ec2-user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 zlib@openssh.com
debug1: kex: client->server aes128-ctr hmac-md5 zlib@openssh.com
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa     SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
debug1: Host 'xxx.xxx.xxx.xxx' is known and matches the RSA host key.
debug1: Found key in /home/mobaxterm/.ssh/known_hosts:21
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: xxxxxxxxx.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

ssh配置没有改变,.pem文件没有改变,IP没有改变。我们已经从不同的设备测试了它,结果是一样的。我们正确使用ec2-user。

终端,Moba Xterm,Jenkins,Putty,Pac Manager无法通过ssh连接。

我们与其他实例具有相同的配置,这是唯一遇到此问题的实例。

该实例是r3.xlarge,它位于us-east-1c,它与静态ip链接。

非常感谢。

1 个答案:

答案 0 :(得分:0)

我不知道原因,但有些内容正在删除ec2-user的authorized_keys文件( /home/ec2-user/.ssh/authorized_keys )。如果您拥有此文件的副本并在原始实例中再次创建,则问题将得到解决。

现在我只需要知道为什么删除这个文件,以及它是如何发生的。