web-dev-qa-db-ja.com

Amazonインスタンスへの.pemファイルを持つsshのアクセス許可が拒否されました(公開キー)

Amazonのインスタンスにログインしようとしています。「。pem」ファイルには600の特権があります。

ssh -v -i FTPServer.pem [email protected]

すべての可能なユーザー「root/ubuntu/ec2-user ..」を試しました。私は常に以下を受け取ります。

    OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com [xx.xxx.xxx.xxx] port 22.
debug1: Connection established.
debug1: identity file FTPServer.pem type -1
debug1: identity file FTPServer.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-8
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-6ubuntu2
debug1: match: OpenSSH_5.1p1 Debian-6ubuntu2 pat OpenSSH_5* compat 0x0c000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<3072<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server Host key: RSA 0f:ad:a5:01:e1:75:82:fa:54:bd:56:53:34:d9:7e:6b
debug1: Host 'ec2-xx-xxx-xxx-xxx.compute-1.amazonaws.com' is known and matches the RSA Host key.
debug1: Found key in /home/myhome/.ssh/known_hosts:6
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: Downloads/FTPServer.pem
debug1: Authentications that can continue: publickey
debug1: Trying private key: FTPServer.pem
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
3
MohammedSimba

この問題は、間違った.pemファイルを使用していたため、Amazonインスタンスでデフォルトユーザー「ubuntu」として正常に接続されたためです。

1
MohammedSimba

作成時にユーザーのカスタムリストを提供しない限り、デフォルトの「ubuntu」ユーザーがまだ存在しているはずであり、EC2キーは通常の構成が取得するようにそのユーザーに配置されています。

他のユーザーで動作させるには、/home/ubuntu/.ssh/authorized_keysから行を取得して、ファイル/home/$USER/.ssh/authorized_keysに配置する必要があります($USERは、特にそれを使用しようとしているユーザー名です)キー)。

ただし、コメントに基づいて、これはEC2インスタンスではなく、実際のログイン手順なしで.pemが与えられただけです。管理者(EC2インスタンスを設定した人)に連絡してログイン手順を要求し、.pemの公開鍵が.ssh/authorized_keysで利用できることを確認するよう指示する必要があります。ログインするユーザーのホームディレクトリにあるファイル。

2
Thomas Ward