Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am unable to access the server, getting a "Permission denied (publickey)." Error

I am able to access it on one system using the same .pem file, but it is giving error on my system.

$ sudo ssh -v -i ./InsticatorPublic.pem ubuntu@54.243.206.17  
[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).  

The auth.log file looks like:

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  
share|improve this question
2  
And you are sure this key is configured on the server? What's in the servers log? – Hauke Laging May 30 '13 at 22:28
    
you can easily say that your key is not the correct one, either from ssh verbose and auth logs. You can see that pam has no issues with the authentication method but the publickey do have issues:-) – ostendali Nov 4 '15 at 16:53

You may want to try looking in /var/log/auth.log to see why the key is being rejected. Most likely answers are that you haven't updated authorized_keys for the user with the required key, or that the authorized keys file has the wrong permissions.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.