If you’re not sure how to view your SSH certificates, this article walks you through the steps on Linux, macOS, and Windows.
There will be times when you need to actually view your SSH certificates on Linux. Why? For example, you need to add a certificate for authentication on GitHub (or any other online service that requires SSH authentication). You know you’ve created those SSH certificates, but how do you view them?
For those who are familiar with SSH, you probably already know the answer to that question. After all, this is pretty basic SSH stuff. For those who are new to the ways of SSH (or Linux, macOS or Windows, for that matter), the task might stump you.
In this article, and the video tutorial above, I’ll show you how easy it is to view those SSH keys, so you can use them for third-party services.
SEE: How to Create and Copy SSH Keys with 2 Simple Commands (TechRepublic)
The only thing you’ll need for this is access to a server or desktop (Linux, macOS, or Windows) and an SSH key created. If you’ve not already created your SSH key pair, you can do so with the command:
ssh-keygen
That command will generate a key pair, both public and private keys. The public key is the one you send to servers for SSH key authentication. When you attempt to log in to that server, SSH will compare the public and private keys. If those keys match, you’ll be allowed access. Simple enough. You’re ready to move on.
There are two easy ways to view your SSH public key in Linux: using the cat command or using both the ssh-agent and ssh-add commands, which is a bit more complicated. The second method is probably overkill for what you need, but it’s a good way to view the key while requiring your SSH keypair password.
ssh-agent sh -c 'ssh-add; ssh-add -L'If you don’t want to have to memorize yet another command, you could simply use the cat command.
cat ~/.ssh/id_rsa.pubSEE: How to Mount Remote Directories with SSH (TechRepublic)
Viewing your keys on MacOS can be done in a similar fashion to Linux.
cat ~/.ssh/id_rsa.pubcat /Users/USERNAME/.ssh/id_rsa.pubmacOS also has one more nifty trick up its sleeve. You can copy the contents of the SSH key directly to the clipboard, without displaying the key, using the pbcopy tool.
cat ~/.ssh/id_rsa.pub | pbcopySEE: How to Use an SSH Config File on macOS for Easier Connections to Your Data Center Servers (TechRepublic)
If you have not generated an SSH Key yet, you can generate one now.
ssh-keygentype ~\.ssh\id_rsa.pubYou can also do something similar to what we did on macOS (copying the SSH public key directly to the clipboard).
type ~\.ssh\id_rsa.pub | clipSEE: Top Commands Linux Admins Need to Know (TechRepublic Premium)
Chances are, you’ll never have to view your private key. After all, that’s the secret in the sauce that’s never on display for anyone to see. But on the off chance you do need to view that key, you can follow the same steps as above, but remove the .pub from the file name in any instance.
Remember, id_rsa is the private key, and id_rsa.pub is the public key. And that’s all there is to viewing your SSH public and private keys on Linux, macOS, and Windows.
Be sure to treat these keys with the care and security they deserve. Although your public key will be handed out to other users and services, that private key needs to be tucked away and never shown to the public.
If you do accidentally release that private key, you’ll need to:
If you leave any trace of that compromised key pair on any server or desktop, you risk allowing someone access.