SSH 访问 AWS EC2 - 权限被拒绝

标签 ssh amazon-ec2 amazon-web-services

我正在尝试使用 SSH 访问 EC2 上的新 Ubuntu 实例。我注意到很多人都遇到了同样的问题,并使用了不同的解决方法,但到目前为止还无法解决这个问题。

任何帮助将不胜感激。

>$ ssh -l ubuntu -v -i TBKEY1.pem ec2-46-137-225-40.ap-southeast-1.compute.amazonaws.com  
>OpenSSH_6.0p1, OpenSSL 1.0.1b 26 Apr 2012  
>debug1: Connecting to ec2-46-137-225-40.ap-southeast-1.compute.amazonaws.com [46.137.225.40] port 22.  
>debug1: Connection established.  
>debug1: identity file TBKEY1.pem type -1  
>debug1: identity file TBKEY1.pem-cert type -1 [-pebug1: Remote protocol version 2.0, remote software version OpenSSH_5.3p1 Debian-3ubuntu6  
>debug1: match: OpenSSH_5.3p1 Debian-3ubuntu6 pat OpenSSH_5*  
>debug1: Enabling compatibility mode for protocol 2.0  
>debug1: Local version string SSH-2.0-OpenSSH_6.0  
>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 77:49:93:95:2f:c5:b2:9c:d3:1b:f0:34:fb:23:b1:8c  
>debug1: Host 'ec2-46-137-225-40.ap-southeast-1.compute.amazonaws.com' is known and matches the RSA host key.  
>debug1: Found key in /home/Ma/.ssh/known_hosts:1       
>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: TBKEY1.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).  

最佳答案

曾经我也遇到过类似的问题。我无法解决它,但我解决了它。您可以做的是从您尝试访问的计算机的 EBS 创建 AMI,然后从该 AMI 启动一个新实例并指定创建新 key 对。然后,AWS 应该将您的新私钥添加到 allowed_keys 中,并让您进入新机器。那时你就可以击落旧的了。

希望这有帮助。

关于SSH 访问 AWS EC2 - 权限被拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10386720/

相关文章:

linux - 需要了解在 ec2-linux 实例中安装 mongodb 服务器的代码

amazon-web-services - 使用云形成将文件从 S3 存储桶复制到 EC2 主目录

php - 传递给 Aws\AwsClient::getCommand() 的参数 2 必须是数组类型,字符串给定

linux - 每次登录远程服务器时警告

ssh - 使用 SSH 隧道转发访问防火墙后的网站

git - 使用多个 Git 用户 SSH key 的权限被拒绝

python - pip 安装 python2.7 的模块而不是 python3.4

javascript - 使用 Node.Js 的 Lambda 函数

java - AWS 开发工具包 2.x DynamoDB 文档 API

php - 使用 php 脚本中的 rsync 同步本地和远程文件夹,无需输入密码