我无法访问服务器,收到“权限被拒绝(公钥)”错误
我能够使用相同的 .pem 文件在一个系统上访问它,但它在我的系统上出现错误。
$ sudo ssh -v -i ./InsticatorPublic.pem [email protected]
[sudo] password for puneet:
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 54.243.206.17 [54.243.206.17] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file ./InsticatorPublic.pem type -1
debug1: identity file ./InsticatorPublic.pem-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.8p1 Debian-7ubuntu1
debug1: match: OpenSSH_5.8p1 Debian-7ubuntu1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
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: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA 63:e9:f2:7f:ab:f2:43:44:9f:64:c7:8e:ad:c5:15:e9
debug1: Host '54.243.206.17' is known and matches the ECDSA host key.
debug1: Found key in /root/.ssh/known_hosts:3
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: ./InsticatorPublic.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).
auth.log文件如下所示:
May 31 10:19:22 puneet-VirtualBox lightdm: pam_unix(lightdm:session): session opened for user lightdm by (uid=0)
May 31 10:19:22 puneet-VirtualBox lightdm: pam_ck_connector(lightdm:session): nox11 mode, ignoring PAM_TTY :0
May 31 10:19:23 puneet-VirtualBox lightdm: pam_succeed_if(lightdm:auth): requirement "user ingroup nopasswdlogin" not met by user "puneet"
May 31 10:19:23 puneet-VirtualBox dbus[791]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.27" (uid=104 pid=1664 comm="/usr/lib/indicator-datetime/indicator-datetime-ser") interface="org.freedesktop.DBus.Properties" member="GetAll" error name="(unset)" requested_reply="0" destination=":1.14" (uid=0 pid=1179 comm="/usr/sbin/console-kit-daemon --no-daemon ")
May 31 10:19:47 puneet-VirtualBox lightdm: pam_unix(lightdm:session): session closed for user lightdm
May 31 10:19:47 puneet-VirtualBox lightdm: pam_unix(lightdm:session): session opened for user puneet by (uid=0)
May 31 10:19:47 puneet-VirtualBox lightdm: pam_ck_connector(lightdm:session): nox11 mode, ignoring PAM_TTY :0
May 31 10:19:49 puneet-VirtualBox polkitd(authority=local): Registered Authentication Agent for unix-session:/org/freedesktop/ConsoleKit/Session2 (system bus name :1.46 [/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1], object path /org/gnome/PolicyKit1/AuthenticationAgent, locale en_US.UTF-8)
May 31 10:19:52 puneet-VirtualBox dbus[791]: [system] Rejected send message, 2 matched rules; type="method_call", sender=":1.58" (uid=1000 pid=2124 comm="/usr/lib/indicator-datetime/indicator-datetime-ser") interface="org.freedesktop.DBus.Properties" member="GetAll" error name="(unset)" requested_reply="0" destination=":1.14" (uid=0 pid=1179 comm="/usr/sbin/console-kit-daemon --no-daemon ")
May 31 10:45:36 puneet-VirtualBox gnome-screensaver-dialog: gkr-pam: unlocked login keyring
May 31 10:46:11 puneet-VirtualBox sudo: puneet : TTY=pts/1 ; PWD=/home/puneet/Insticator/GitConnect ; USER=root ; COMMAND=./connectdemo
May 31 10:46:11 puneet-VirtualBox sudo: pam_unix(sudo:session): session opened for user root by puneet(uid=1000)
May 31 10:46:12 puneet-VirtualBox sudo: pam_unix(sudo:session): session closed for user root
答案1
您可能需要尝试查看 /var/log/auth.log 以查看密钥被拒绝的原因。最可能的答案是您尚未使用所需密钥更新用户的 authorized_keys,或者授权密钥文件具有错误的权限。