How to test password for a private SSH key?
If id_rsa and id_rsa.pub is a keypair, we can execute (after we go to directory whey they reside like e.g. cd ~/.ssh/):
$ ssh-keygen -y -f id_rsa
...which will prompt us to enter the password. If correct, this will output the public key.
-y This option will read a private OpenSSH format file and print an OpenSSH public key to stdout.
-f filename Specifies the filename of the key file.
If you download key pair from another machine, this operation might fail with error:
$ ssh-keygen -y -f id_rsa
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: UNPROTECTED PRIVATE KEY FILE! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0664 for 'id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "id_rsa": bad permissions
$ chmod 400 id_rsa
If private key is not password protected, user will not be prompted to enter it.
Resources:
ssh keys - How do I verify/check/test/validate my SSH passphrase? - Stack Overflow
command line - How do I retrieve the public key from a SSH private key? - Ask Ubuntu
No comments:
Post a Comment