77

最近、新しい EC2 インスタンスをセットアップしました。翌日、ssh 経由でインスタンスに接続できませんでした。前日は接続と切断ができましたが、何もしなかったと確信しています。ssh デバッグ情報は次のとおりです。

ssh -i webserver.pem -v ubuntu@my.elastic.ip
OpenSSH_5.9p1, OpenSSL 0.9.8r 8 Feb 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to my.elastic.ip [my.elastic.ip] port 22.
debug1: Connection established.
debug1: identity file webserver.pem type -1
debug1: identity file webserver.pem-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9
debug1: SSH2_MSG_KEXINIT sent
Connection closed by my.elastic.ip

この問題を解決する方法はありますか? または、インスタンスを再インストールしますか?

私の .pem に対する PS 権限は 600 に設定されています。

4

10 に答える 10

45

多くの場合、インスタンスの起動に使用した AMI のデフォルトのユーザー名を使用する必要があります。

  • Amazon Linux 2 または Amazon Linux AMI の場合、ユーザー名は
    ec2-user です。

  • CentOS AMI の場合、ユーザー名は centos です。

  • Debian AMI の場合、ユーザー名は admin または root です。

  • Fedora AMI の場合、ユーザー名は ec2-user または fedora です。

  • RHEL AMI の場合、ユーザー名は ec2-user または root です。

  • SUSE AMI の場合、ユーザー名は ec2-user または root です。

  • Ubuntu AMI の場合、ユーザー名は ubuntu です。

    それ以外の場合、ec2-user と root が機能しない場合は、AMI プロバイダーに確認してください。

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connection-prereqs.html#connection-prereqs-get-info-about-instance

于 2019-09-14T20:28:17.390 に答える
13

セキュリティグループを確認してください。インスタンスから戻るトラフィックを許可する送信ルールがあることを確認してください。

デフォルトの送信ルールを使用

type: All traffic, Protocol: All, Ports: All, Destination: 0.0.0.0/0

それが動作します。

于 2015-01-13T15:03:06.137 に答える