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

Are there any command I can verify the public key (, just the format only

Sometimes I have added a new linebreak, sometimes the file missed the ssh-rsa prefix, so are there any command to validate?

share|improve this question

2 Answers 2

up vote 26 down vote accepted

You can use ssh-keygen for this. Despite its name it can do many more things than generating keys:

dennis@lightning:~$ ssh-keygen -l -f .ssh/ 
2048 68:df:b2:22:d8:43:5d:36:75:c1:d8:59:c0:8c:22:e8  Dennis Kaarsemaker (RSA)
dennis@lightning:~$ ssh-keygen -l -f foo.txt
foo.txt is not a public key file.
share|improve this answer

I have not come across any program that will do that for you. You can always try and script it. But as a rule of thumb, you don't ever need to edit your Best way to be sure of keeping your formatting is using the ssh-copy-id command, when you are adding you public keys to other servers.

share|improve this answer

Your Answer


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.