SSH Public Key Format

Solution 1:

use ssh-keygen -i to convert SSH2-compatible format to OpenSSH compatible format.

from man ssh-keygen:

-i This option will read an unencrypted private (or public) key file in SSH2-compatible format and print an OpenSSH compatible private (or public) key to stdout. ssh-keygen also reads the RFC 4716 SSH Public Key File Format. This option allows importing keys from several commercial SSH implementations.

Solution 2:

This is the complete, correct answer:

ssh-keygen -i -m PKCS8 -f public-key.pem


Solution 3:

You do have to convert the public key to openssh convention:

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIBmhLUTJiP[and so on]== somename-20060227

Also make sure that the key occupies exactly one line and no line breaks were introduced while copying.


Solution 4:

Just rewrite your key in format suited for authorized_keys:

keytype keybody keyname

Keep in mind that trailing "==" are necessary placeholders to keep keylength equal to desired length.