Search code examples
sshopenssh

Why does Private key appear password protected with no EOL?


I've a server setup which is accessed via SSH by pulling a key from an external secure server. The SSH key is not password protected however asks for a password when I try to access the server:

Enter passphrase for key 'my-key'

When I view the key using vi, it has a noeol message at the end of the file

-----BEGIN OPENSSH PRIVATE KEY-----

...
...
-----END OPENSSH PRIVATE KEY-----
~
~
~
~
~
~
~
~/.ssh/my-key" [noeol] 27L, 1798C

This is rectified when I append \n when copying the key. Why does a lack of EOL cause the key to look for a password?


Solution

  • It can be because of the (proprietary) OPENSSH private key format, described here, which includes:

    • A format ID prefix
    • Encryption headers
    • An unused number for number of keys in the block
    • An rfc4253-style ssh public key
    • An private key somewhat modeled after the rfc4253 style
    • A comment
    • Padding for aligning private key to the blocksize