SSH를 통해 AWS 인스턴스에 연결하는 방법은 무엇입니까?
나는 가지고있다:
- AWS에 가입했습니다.
- AWS 웹 사이트에서 퍼블릭 키와 인증서를 생성하여 디스크에 저장했습니다.
-
내 콘솔로 가서 환경 변수를 만들었습니다.
$ export JAVA_HOME=/usr/lib/jvm/java-6-openjdk/ $ export EC2_CERT=/home/default/aws/cert-EBAINCRNWHDSCWWIHSOKON2YWGJZ5LSQ.pem $ export EC2_PRIVATE_KEY=/home/default/aws/pk-EBAINCRNWHDSCWWIHSOKON2YWGJZ5LSQ.pem
-
이 키 페어를 사용하도록 AWS API를 말하고 키 페어를 파일에 저장했습니다.
$ ec2-add-keypair ec2-keypair > ec2-keypair.pem
-
이 키 페어를 사용하여 AWS Ubuntu 9 인스턴스를 시작했습니다.
$ ec2-run-instances ami-ed46a784 -k ec2-keypair
-
인스턴스에 ssh 연결을 설정하려고 시도했습니다.
$ ssh -v -i ec2-keypair.pem ubuntu@ec2-174-129-185-190.compute-1.amazonaws.com OpenSSH_5.1p1 Debian-5ubuntu1, OpenSSL 0.9.8g 19 Oct 2007 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Applying options for * debug1: Connecting to ec2-174-129-185-190.compute-1.amazonaws.com [174.129.185.190] port 22. debug1: Connection established. debug1: identity file ec2-keypair.pem type -1 debug1: Remote protocol version 2.0, remote software version OpenSSH_5.1p1 Debian-5ubuntu1 debug1: match: OpenSSH_5.1p1 Debian-5ubuntu1 pat OpenSSH* debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_5.1p1 Debian-5ubuntu1 debug1: SSH2_MSG_KEXINIT sent debug1: SSH2_MSG_KEXINIT received debug1: kex: server->client aes128-cbc hmac-md5 none debug1: kex: client->server aes128-cbc 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: Host 'ec2-174-129-185-190.compute-1.amazonaws.com' is known and matches the RSA host key. debug1: Found key in /home/default/.ssh/known_hosts:11 debug1: ssh_rsa_verify: signature correct 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: ec2-keypair.pem debug1: read PEM private key done: type RSA debug1: Authentications that can continue: publickey debug1: No more authentication methods to try. Permission denied (publickey).
무엇이 문제이고 어떻게 작동하게 할 수 있습니까?
답변
우분투 인스턴스의 경우 :
chmod 600 ec2-keypair.pem
ssh -v -i ec2-keypair.pem ubuntu@ec2-174-129-185-190.compute-1.amazonaws.com
다른 경우에는 ec2-user
대신 대신 사용해야 할 수도 있습니다 ubuntu
.
내가 사용한 대부분의 EC2 Linux 이미지에는 기본적으로 루트 사용자 만 생성됩니다.
답변
이제는 :
ssh -v -i ec2-keypair.pem ec2-user@[yourdnsaddress]
답변
Canonical의 릴리스는 기본적으로 사용자 ‘ubuntu’를 사용하여 동일한 문제가 발생하는 우분투 이미지로 여기에 방문하는 모든 사람에게 사용됩니다.
답변
Bitnami 이미지를 사용하는 경우 ‘bitnami’로 로그인하십시오.
명백해 보이지만 내가 간과 한 것.
답변
내 우분투 이미지의 경우 실제로는 우분투 사용자이며 ec2-user는 아닙니다.)
답변
openSSH가 포함 된 Ubuntu 10.04
이것은 정확한 사용법입니다.
ssh -v -i [yourkeypairfile] ec2-user@[yourdnsaddress]
예를 들면 다음과 같습니다.
ssh -v -i GSG_Keypair.pem ec2-user@ec2-184-72-204-112.compute-1.amazonaws.com
위의 예제는 http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/ 에서 Linux / UNIX 머신에 연결하기위한 AWS 자습서에서 직접 가져 왔습니다.
답변
또한 pem 파일 권한이 너무 열려 있는지 불평합니다. 이를 수정하려면 파일을 600으로 chmod하십시오.
