How to Check if *.pem is Password Protected Using ssh-keygen

ssh-keygensslssl-certificate

I have got a file myfile-privkey.pem.

How do I check if the private key file is password protected using ssh-keygen?

Best Answer

ssh-keygen -y -f myfile-privkey.pem

If the key is password protected, you will see a "password:" prompt.

The flags in this command are:

-y Read private key file and print public key.
-f Filename of the key file.

As extra guidance, always check the command someone, especially online, is telling you to use when dealing with your private keys.