【问题标题】:Amazon Linux AMI ec2 instance Permission denied (Public key)Amazon Linux AMI ec2 实例权限被拒绝(公钥)
【发布时间】:2016-08-04 08:34:23
【问题描述】:

AWS 中的一个实例经常出现问题。

问题如下:

该实例是一个 Amazon Linux AMI,其中包含一个 Tomcat 6 服务器并启用了 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。

Terminal、Moba Xterm、Jenkins、Putty、Pac Manager 无法通过 ssh 连接。

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

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

非常感谢。

【问题讨论】:

  • 我们使用的紧急解决方案是从原始实例启动 AMI 并将原始卷附加到新实例。
  • 可能是一些脚本删除/禁用用户 ec2_user,也许是一些“强化”过程?
  • 没有修改ec2-user,而且这种情况也只是偶尔发生......,没有模式......

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


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 2016-02-17
    • 1970-01-01
    • 2014-01-28
    • 1970-01-01
    • 1970-01-01
    • 2018-10-01
    • 2017-09-07
    • 1970-01-01
    • 2017-07-03
    相关资源
    最近更新 更多