Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a public key in the format:

---- BEGIN SSH2 PUBLIC KEY ----

Comment: "somename-20060227" AAAAB3NzaC1yc2EAAAABJQAAAIBmhLUTJiP[and so on]==

---- END SSH2 PUBLIC KEY ----

usually i see keys in the format like this:

ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAqof[and so on]

Can I just copy the first key in the authorized_keys file or do I have to modify it somehow so it looks like the second one? I think the first one was generated by PUTTYgen while the second one was generated by ssh-keygen.

share|improve this question

3 Answers 3

up vote 4 down vote accepted

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

-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.

share|improve this answer

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.

share|improve this answer
1  
The trailing "==" are Base64 padding –  Andrew Apr 18 '12 at 14:46
    
how do I know if its RSA or DSA? –  Marcel Apr 18 '12 at 16:07

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.

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.