web-dev-qa-db-ja.com

Macのターミナル経由でEC2インスタンスに接続する

私はコーディングにまったく慣れておらず、courseraでスタートアップコースを受講しています: https://class.coursera.org/startup-001/lecture/87

AWSで作成したEC2Ubuntuインスタンスに接続しようとすると、アクセス許可が拒否されました(公開鍵)

  1. AWSIstanceを設定する
  2. セキュリティをデフォルトに設定し、ポート22を追加して起動しました
  3. コースでは、次のように入力するように指示されています。

    chmod 400 trevor-learning.pem ssh -i trevor-learning.pem\[email protected]

これにより、次のエラーが発生します:アクセスが拒否されました(公開鍵)。

他の質問を見て、ubuntu @をec2-userなどに切り替えてみましたが、まだ接続できません。

私も試しました:trevor-larsons-macbook-pro:downloads trev $ chmod 600 trevor-learning.pem trevor-larsons-macbook-pro:downloads trev $ ssh -v -i trevor-learning ubuntu @ ec2-XX-XXX-XX -XX.us-west-2.compute.amazonaws.com

それは私に与えました:

OpenSSH_5.9p1, OpenSSL 0.9.8x 10 May 2012
Warning: Identity file trevor-learning not accessible: No such file or directory.
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to ec2-XX-XXX-XX-XX.us-west-2.compute.amazonaws.com [XX.XXX.XX.XX] port     22.
debug1: Connection established.
debug1: identity file /Users/trev/.ssh/id_rsa type -1
debug1: identity file /Users/trev/.ssh/id_rsa-cert type -1
debug1: identity file /Users/trev/.ssh/id_dsa type -1
debug1: identity file /Users/trev/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1 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
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<1024<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 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
debug1: Host 'ec2-XX-XXX-XX-XX.us-west-2.compute.amazonaws.com' is known and matches the RSA Host key.
debug1: Found key in /Users/trev/.ssh/known_hosts:2
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: Trying private key: /Users/trev/.ssh/id_rsa
debug1: Trying private key: /Users/trev/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).

ここで途方に暮れて、私が何をしているのかわからないので助けてください!

また、これがそれと関係があるかどうかはわかりませんが、インスタンス証明書をダウンロードすると(chromeブラウザの左下に表示され、キーチェーンアクセスが開き、エラーが発生しました」と表示されます。アイテムをインポートできません。このアイテムのコンテンツを取得できません。」

8
funitect

ターミナルで次の手順を試してください。

ssh-keygen -R 12.345.678.999 // This Reset your publickey

次に、EC2のキーペア名およびパブリックDNSでアクセスしてみます。

ssh -i KeyPairName.pem [email protected]
10
Black Sheep