Question
How to verify if a public and private RSA SSH key match?
Answer
Warning: The commands below will show the contents of your SSH public and private keys. You should not share your SSH private keys with anyone, for any reason.
- Access the server as
rootusing SSH or the Terminal in WHM - Navigate to the folder that holds your SSH keys. By default, these are stored in the
.sshfolder in a user's home directory. This folder will contain both the private and public keys, such as the following:
# ls -alh /root/.ssh/id_*
-rw------- 1 root root 2.6K Jul 31 00:02 /root/.ssh/id_rsa
-rw-r--r-- 1 root root 580 Jul 31 00:02 /root/.ssh/id_rsa.pubNote: For cPanel users, SSH keys are stored in the user's home directory at:
/home/USER/.sshUse the
ssh-keygencommand to test the files and print critical information:. The output of the command will contain theSHA256signature for the key.Private Key:
# ssh-keygen -l -f id_rsa
2048 SHA256:abcdef123456789 user@domain.tld (RSA)Public Key:
# ssh-keygen -l -f id_rsa.pub
2048 SHA256:abcdef123456789 user@domain.tld (RSA)If the signatures match, then these SSH keys match.
Comments
0 comments
Article is closed for comments.