Reputation: 1128
I'm building a small service where users may upload their public SSH key in order to access a Mercurial repository (via SSH). I'd like to verify that whatever the users paste is:
ssh-keygen -l -f pasted_key_put_in_a_file
exit code is 0)From what I understand, ssh-keygen -l -f ...
doesn't say whether the key part inspected is the public or private part.
Is there a way to verify that a file does not contain/represent the private part of a key pair?
Upvotes: 1
Views: 680
Reputation: 1128
It turns out that ssh-keygen -l -f private_key
will look for a matching public_key
in the same directory as private_key
and use that if found. But if there is no such (by name) matching public key part, the private_file
will be tried and the program complains. So the command I thought couldn't be used, can in fact be used (as long as there's no public key part in a file next to it with a matching name).
Upvotes: 1