Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services 为什么可以';我不能使用ssh访问这个EC2实例吗?_Amazon Web Services_Ssh_Amazon Ec2 - Fatal编程技术网

Amazon web services 为什么可以';我不能使用ssh访问这个EC2实例吗?

Amazon web services 为什么可以';我不能使用ssh访问这个EC2实例吗?,amazon-web-services,ssh,amazon-ec2,Amazon Web Services,Ssh,Amazon Ec2,这个问题已经被问了很多次,也被回答了很多次(今天我已经读了很多),但是我仍然不知道尝试ssh到EC2实例中有什么不对。以下是我所做的: 这是一个EC2中型实例,运行ubuntu Linux。 我创建了一个新的密钥对并下载了rick_casey.pem文件, 将其移动到~/.ssh,并执行了此操作 chmod 400 rick_casey.pem 然后将其添加到我的ssh标识中: ssh-add rick_casey.pem 但当我尝试连接时,会发生以下情况: ssh -v -i "rick_

这个问题已经被问了很多次,也被回答了很多次(今天我已经读了很多),但是我仍然不知道尝试ssh到EC2实例中有什么不对。以下是我所做的:

这是一个EC2中型实例,运行ubuntu Linux。 我创建了一个新的密钥对并下载了rick_casey.pem文件, 将其移动到~/.ssh,并执行了此操作

chmod 400 rick_casey.pem
然后将其添加到我的ssh标识中:

ssh-add rick_casey.pem
但当我尝试连接时,会发生以下情况:

ssh -v -i "rick_casey.pem" ubuntu@ec2-54-237-54-42.compute-1..amazonaws.com
OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /Users/rickcasey/.ssh/config
debug1: /Users/rickcasey/.ssh/config line 8: Applying options for *.amazonaws.com
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 53: Applying options for *
debug1: Connecting to ec2-54-237-54-42.compute-1.amazonaws.com [54.237.54.42] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file rick_casey.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file rick_casey.pem-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/rickcasey/.ssh/rick_casey.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/rickcasey/.ssh/rick_casey.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.6 pat OpenSSH_6.6.1* compat 0x04000000
debug1: Authenticating to ec2-54-237-54-42.compute-1.amazonaws.com:22 as 'ubuntu'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client chacha20-poly1305@openssh.com <implicit> none
debug1: kex: client->server chacha20-poly1305@openssh.com <implicit> none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:Zu9shRhr3d+STyKTHKkhE2ZC1esSrALqNPGj3UtN8IA
Warning: Permanently added 'ec2-54-237-54-42.compute-1.amazonaws.com,54.237.54.42' (ECDSA) to the list of known hosts.
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: Offering RSA public key: rick_casey.pem
debug1: Authentications that can continue: publickey
debug1: Trying private key: rick_casey.pem
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/rickcasey/.ssh/rick_casey.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
有人知道这是什么意思吗?这是否与公钥有关?当您生成一个AWS密钥对时,公钥不是自动添加到AWS服务器的应该位置吗

其他用户可以通过ssh连接到此服务器而没有问题,因此我没有理由不能做同样的事情……但是有人对我应该尝试什么有建议吗

谢谢, 瑞克

当您生成一个AWS密钥对时,公钥不是自动添加到AWS服务器的应该位置吗

当然不会,除非您正在使用该键启动一个新的实例。您提到其他用户可以登录,这意味着这不是您使用此密钥启动的实例

要在现有实例上使用新密钥,您必须将私钥对应的公钥附加到/home/ubuntu/.ssh/authorized_-keys(或“ec2用户”,或任何用户名——Amazon Linux使用“ec2用户”,ubuntu使用“ubuntu”)。。。但当然,在这种情况下,没有理由使用EC2控制台生成密钥。。。您可以通过在本地生成私钥来实现相同的结果


但是,由于您已经拥有密钥,因此可以使用
ssh-keygen-y-f/path/to/your private key.pem
从私钥中提取公钥,并将其提供给管理员,谁需要将其添加到服务器的用户授权密钥文件中。

您可以删除已知主机并重试吗?请另一个用户登录,并检查您的新密钥是否存在于服务器的授权密钥中。如果不是,请添加到那里。“ubuntu”是正确的用户名吗?你的用户名是什么?使用它而不是
ubuntu
我的实例中至少有一半是ubuntu,而且我一直都必须使用
ec2 user
作为登录名。
debug1: key_load_public: No such file or directory