In that location will be times when you need to actually view your SSH certificates in Linux. Why? Say, for case, you demand to add a document for hallmark in GitHub (or any other online service that requires SSH authentication). You know you've created those SSH certificates, only how practice you lot view them?

For those who are familiar with SSH, you lot probably already know the answer to that question. Afterward all, this is pretty bones SSH stuff. For those who are new to the ways of SSH (or Linux, macOS, or Windows for that thing), the job might stump yous.

Never fright, that'south why I'm here.

I desire to evidence you just how easy information technology is to view those SSH keys, so you can use them for third-political party services.

SEE: Identity theft protection policy (TechRepublic Premium)

What y'all'll need

The merely affair you'll demand for this is admission to a server or desktop (Linux, macOS, or Windows) and an SSH key created. If you lot've not already created your SSH fundamental pair, you can do and then with the command:

ssh-keygen

That control will generate a central pair, both public and individual keys. The public key is that which yous send to servers for SSH fundamental hallmark. When you attempt to log in to that server, SSH will compare the public and private keys. If those keys are a match, you'll exist allowed admission. Elementary enough. You're set up to move on.

How to view your SSH public fundamental on Linux

There are 2 easy ways to view your SSH public key in Linux. The first method is a scrap complicated, because it makes use of both ssh-agent and ssh-add together commands. This is probably overkill for what you need, merely it's a skillful style to view the key, while requiring your SSH keypair password. The command is:

ssh-agent sh -c 'ssh-add together; ssh-add -L'

Upon successful authentication, your SSH public key volition print out in the terminal. Yous tin can and then copy that and paste it where you need. Of class, that's a lot of commands to think, specially when you just need to view the contents of the public key.

If you don't desire to take to memorize still another command, you lot could simply use the cat command like and then:

true cat ~/.ssh/id_rsa.pub

The above command will print out your SSH key on your Linux motorcar, without prompting you lot for your key authentication countersign.

How to view your SSH public key on macOS

Viewing your keys on macOS tin exist done in similar fashion as Linux. Open your concluding window and issue the command:

cat ~/.ssh/id_rsa.pub

Or:

cat /Users/USERNAME/.ssh/id_rsa.pub

Where USERNAME is your macOS username.

The above commands will print out your SSH public fundamental.

macOS also has one more swell play a joke on up its sleeve. You tin re-create the contents of the SSH cardinal directly to the clipboard, without displaying the key, using the pbcopy tool. This command would be:

cat ~/.ssh/id_rsa.pub | pbcopy

Once you've copied the primal to your clipboard, y'all can paste it wherever you demand it.

How to view your SSH public central on Windows

On Windows, you'll utilise the type control to view your SSH public key like and so:

blazon C:UsersUSERNAME.sshid_rsa.pub

Where USERNAME is the name of your user.

The above command will display your SSH public key. You can and so utilise the Ctrl+c keyboard shortcut to copy the contents of the file.

You can also exercise something similar to what nosotros did on macOS (copying the SSH public key directly to the clipboard) using the type and prune commands like so:

type C:UsersUSERNAME.sshid_rsa.pub | prune

Where USERNAME is your username.

You can now paste that key wherever you need it.

How to view your individual cardinal

Chances are you're non ever going to accept to view your individual key. After all, that's the secret in the sauce that'south never on display for anyone to meet. But, on the off chance yous practice need to view that key, y'all can follow the aforementioned steps as above, but remove the .pub from the file name (in whatsoever instance). Recall id_rsa is the private central and id_rsa.pub is the public key.

And that's all in that location is to viewing your SSH public and private keys on Linux, macOS, and Windows.

Only call back, treat these keys with the intendance and security they deserve. Although your public cardinal will exist 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 fundamental, you lot'll need to remove the public key from the authorized_keys file from every server that uses the keypair, delete the public and private keys on the host, generate a new keypair, and send it to the servers yous need to log in to with SSH cardinal hallmark. If you get out any trace of that compromised central pair on whatsoever server or desktop, you run the hazard of assuasive someone access.

Subscribe to TechRepublic's How To Make Tech Work on YouTube for all the latest tech advice for business pros from Jack Wallen.


Paradigm: iStock/Stock Depot