linux - 亚马逊 EC2 实例 "Permission denied (publickey)"

标签 linux amazon-web-services amazon-ec2 ssh

我一直使用此命令通过 SSH 访问我的服务器

ssh -i "KeyPair.pem" <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="27524552495352671215091511091512120917" rel="noreferrer noopener nofollow">[email protected]</a>

今天我尝试了相同的命令并收到此错误消息

Permission denied (publickey)

使用-v选项我收到了这条消息

OpenSSH_6.6.1, OpenSSL 1.0.1m 19 Mar 2015
debug1: Connecting to 52.26.255.0 [52.26.255.0] port 22.
debug1: Connection established.
debug1: identity file C:\\Users\\Jacob\\Google Drive\\KeyPair.pem type -1
debug1: identity file C:\\Users\\Jacob\\Google Drive\\KeyPair.pem-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="10787d71733d7d74253d75647d507f60757e6363783e737f7d" rel="noreferrer noopener nofollow">[email protected]</a> none
debug1: kex: client->server aes128-ctr <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="741c1915175919104159110019341b04111a07071c5a171b19" rel="noreferrer noopener nofollow">[email protected]</a> none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA e3:51:6f:9a:ed:2f:a2:dd:50:9d:19:a2:0a:f4:88:10
debug1: Host '52.26.255.0' is known and matches the ECDSA host key.
debug1: Found key in /.ssh/known_hosts:2
debug1: ssh_ecdsa_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: C:\\Users\\Jacob\\Google Drive\\KeyPair.pem
debug1: key_parse_private2: missing begin marker
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).

我没有修改我的 KeyPair.pem 文件(“修改日期”= 2015 年 9 月 24 日)

一件非常重要的事情。在最后成功授权的时间我在服务器上执行了下一个命令:

home> chmod -R 777 ubuntu/

上面的命令是否可能破坏了我对服务器的访问权限?

最佳答案

主页> chmod -R 777 ubuntu/

是罪魁祸首。您的/home/ubuntu/.ssh 目录必须为 700,而/home/ubuntu/.ssh/authorized_keys 必须为 600。既然他们现在是777,那么你就不走运了。但是有一些方法可以恢复它。搜索 StackOverflow。

关于linux - 亚马逊 EC2 实例 "Permission denied (publickey)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33741740/

相关文章:

linux - bash find -exec 有时有效,有时无效

linux - 终端如何知道它要应用哪个功能?

python-2.7 - 使用 Lambda 在 ec2 上执行脚本时出现问题

amazon-web-services - 如何在 Elastic Beanstalk 环境中使用 IMDSv2?

amazon-ec2 - noSQL Amazon ec2(有什么建议吗?)

java - 如何告诉 Java 运行这个 Runtime.getRuntime().exec,而不用等待它必须运行的任何命令,只需在后端运行它?

linux - 将多轨+字幕 .MKV 转换为 MP4

python - 如何使用 boto3 以文件系统样式检索存储桶前缀

postgresql - Amazon RDS 不支持扩展 "mysql_fdw"

node.js - AWS EC2 : Ubuntu Webserver - Process out of memory when running npm install