【发布时间】:2016-02-17 22:14:42
【问题描述】:
我一直使用这个命令通过 SSH 访问我的服务器
ssh -i "KeyPair.pem" ubuntu@52.26.255.0
今天我尝试了相同的命令并收到此错误消息
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 hmac-md5-etm@openssh.com none
debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com 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 文件(“修改日期”= 24-Sep-15)
一件很重要的事情。最后成功授权的时候我在服务器上执行了下一条命令:
home> chmod -R 777 ubuntu/
有没有可能,上面的命令破坏了我对服务器的访问权限?
【问题讨论】:
-
OpenSSH(客户端)不需要自己的格式密钥文件吗? (您确定 PEM 适用于它吗?)。通常在 2 个文件中,例如“id_rsa”和“id_rsa.pub”,然后使用
-i id_rsa。是的,你不允许拥有一个世界可写的/home/ubuntu/.ssh目录(这是chmod -R 777 ...导致的),SSH 不会让你使用公钥,因为任何具有 shell 访问权限的人都可以替换它。这假定您的用户名是ubuntu。也许这有助于superuser.com/questions/215504/… -
你用什么
ami-id来部署实例?试试ssh -i "KeyPair.pem" ec2-user@52.26.255.0。
标签: linux amazon-web-services ssh amazon-ec2 amazon