Permission denied for *.pem file

8,096

Go back and look at the actual text of your .pem file. It must look like this :

-----BEGIN RSA PRIVATE KEY-----
.
. (20 odd lines of key)
.
-----END RSA PRIVATE KEY-----

It is complaining about the "beginning marker", so did you delete or alter this at all ? Recommend re-copying. The .ppk is generally used for PuTTY, especially from Windows.

EDIT , take II

I can only suggest having a look at a hexdump then, and you may have to regenerate. Also name it .pem if it is a .pem file and either have it in the same folder (~ ?) you launch from or specify a path. (~/.ssh/xxxx.pem).
On the server the ~/.ssh/authorized_keys folder is conventional, but from the command line on a client the .pem file can be anywhere.

Share:
8,096

Related videos on Youtube

ninja.stop
Author by

ninja.stop

Updated on September 18, 2022

Comments

  • ninja.stop
    ninja.stop over 1 year

    I have *.pem and *.ppk file for my server I tried to ssh into it using that. But it showed permission Denied. I took verbose log for that. But I am not able to understand why it said permission denied. It was distributed to other people and they are abled to log in with same key from windows. But from my ubuntu I am not able to log in. I am enlisting my steps here L

    Downloaded ppk and ppm files moved to .ssh folder Then

    chmod 400 *.ppm
    chmod 400 *.ppk
    
    chown $USER:$USER *.ppk
    chown $USER:$USER *.ppm
    
    ssh -i -v *.ppm [email protected]
    

    Then came the debug :

    OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
    debug1: Reading configuration data /etc/ssh/ssh_config
    debug1: /etc/ssh/ssh_config line 19: Applying options for *
    debug1: Connecting to ip.ip.ip.ip [ip.ip.ip.ip] port 22.
    debug1: Connection established.
    debug1: permanently_set_uid: 0/0
    debug1: identity file *.pem type -1
    debug1: identity file *.pem-cert type -1
    debug1: Enabling compatibility mode for protocol 2.0
    debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
    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 [email protected] none
    debug1: kex: client->server aes128-ctr [email protected] none
    debug1: sending SSH2_MSG_KEX_ECDH_INIT
    debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
    debug1: Server host key: ECDSA AA:BB:CC:99:92:67:90:78:56:vv:tt:9l:6y:c7g:67:78
    debug1: Host 'ip.ip.ip.ip' 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: *.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)
    

    Let me know if any other verbose is needed.

  • ninja.stop
    ninja.stop almost 9 years
    It was there. Still problem.
  • mckenzm
    mckenzm almost 9 years
    I can only suggest having a look at the hexdump then, and you may have to regenerate.
  • mckenzm
    mckenzm almost 9 years
    And just in case, go back to your /etc/ssh/sshd_config on the server and make sure it allows RSA.