繁体   English   中英

尝试通过SSH进入Amazon EC2时出现“权限被拒绝(公钥)。”

[英]“Permission denied (publickey).” while trying to SSH into Amazon EC2

我在AWS上安装了iPython,可以很好地通过浏览器访问它。 但是,当我尝试SSH到EC2实例时,出现以下错误:

Permission denied (publickey).

我尝试使用现有的.pem密钥,以及通过生成新密钥,仍然没有任何效果。 这些是我遵循的步骤:

  1. $ chmod 700〜/ .ssh
  2. cp〜/ desktop / aws / ipython.pem〜/ .ssh / ipython.pem
  3. chmod 600〜/ .ssh / ipython.pem
  4. ssh -i〜/ .ssh / ipython.pem ubuntu@50.174.xx.xx

在运行ssh命令“ ssh -i〜/ .ssh / ipython.pem ubuntu@50.174.xx.xx -v”时,我得到以下响应:

OpenSSH_6.9p1, LibreSSL 2.1.8
debug1: Reading configuration data /Users/coffeeman/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: /etc/ssh/ssh_config line 102: Applying options for *
debug1: Connecting to 50.174.xx.xx [50.174.xx.xx] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /Users/coffeeman/.ssh/ipython.pem type -1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/coffeeman/.ssh/ipython.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 50.174.xx.xx: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:uBRsbvwsIcqNN7vUfzpIXd6n7W5cpyGyU0DutxEHJE8E
debug1: Host '50.174.xx.xx' is known and matches the ECDSA host key.
debug1: Found key in /Users/coffeeman/.ssh/known_hosts:10
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: /Users/coffeeman/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /Users/coffeeman/.ssh/ipython.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

我究竟做错了什么?

看来您没有使用此密钥创建EC2实例。 这是怎么做的

  • 转到EC2控制台
  • 单击Launch an instance ,然后选择您的操作系统,实例类型等。
  • 您将转到此窗口

在此处输入图片说明

  • 从选项列表中选择“ Create a new key pair ”并为其命名,例如ipython
  • 点击Download keypair
  • 将此存储在〜/ .ssh / ipython.pem中
  • 使用SSH通过SSH连接到您的实例

    ssh -i ~/.ssh/ipython.pem your-ip

而且一切都应该没问题! :)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM