How to View Your SSH Keys in Linux, macOS and Windows | TechRepublic (2024)

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? Say, 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?

SEE: Explore this identity theft protection policy from TechRepublic Premium.

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.

Never fear, that’s why I’m here.

I want to show you just how easy it is to view those SSH keys, so you can use them for third-party services.

Featured Partners: Remote Monitoring and Management Software

TechRepublic is able to offer our services for free because some vendors may pay us for web traffic or other sales opportunities. Our mission is to help technology buyers make better purchasing decisions, so we provide you with information for all vendors — even those that don’t pay us.

1Zoho AssistVisit WebsiteCompany SizeEmployees per Company SizeMicro (0-49), Small (50-249), Medium (250-999), Large (1,000-4,999), Enterprise (5,000+)Any Company SizeAny Company SizeFeaturesAnalytics / Reports, API, Document Management / Sharing, and more
2HubstaffVisit WebsiteCompany SizeEmployees per Company SizeMicro (0-49), Small (50-249), Medium (250-999), Large (1,000-4,999), Enterprise (5,000+)Any Company SizeAny Company SizeFeaturesAPI, Budget / Expense Tracking, Time Tracking
3NinjaOneVisit WebsiteCompany SizeEmployees per Company SizeMicro (0-49), Small (50-249), Medium (250-999), Large (1,000-4,999), Enterprise (5,000+)Small (50-249 Employees), Medium (250-999 Employees), Large (1,000-4,999 Employees), Enterprise (5,000+ Employees)Small, Medium, Large, EnterpriseFeaturesMonitoring, Patch Management

What you’ll need

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 that which 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 are a match, you’ll be allowed access. Simple enough. You’re ready to move on.

How to view your SSH public key on Linux

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.

Using the ssh-agent command

  1. Run the command:
    ssh-agent sh -c 'ssh-add; ssh-add -L'
  2. Upon successful authentication, your SSH public key will print out in the terminal.
  3. You can then copy that and paste it where you need it.

If you don’t want to have to memorize yet another command, you could simply use the cat command.

Using the cat command

  1. Run the command:
    cat ~/.ssh/id_rsa.pub
  2. The command will print out your SSH key on your Linux machine without prompting you for your key authentication password.

How to view your SSH public key on macOS

Viewing your keys on macOS can be done in a similar fashion as on Linux.

To view the SSH public key on macOS

  1. Open your terminal window, and run the command
    cat ~/.ssh/id_rsa.pub

    or

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

    Where USERNAME is your macOS username.

  2. The above commands will print out your SSH public key.

macOS 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.

To copy the SSH public key on Mac

  1. Run the command:
    cat ~/.ssh/id_rsa.pub | pbcopy
  2. Once you’ve copied the key to your clipboard, you can paste it wherever you need it.

How to view your SSH public key on Windows

If you have not generated an SSH Key yet, you can generate one now.

To generate an SSH public key on Windows

  1. Run the command:
    ssh-keygen
  2. You’ll be asked where to save the key.
  3. If you use the defaults, it will save your keys in C:\User[YourUserName].sshid.
  4. You will then be prompted to enter a passphrase. You can hit Enter for an empty/no passphrase.
  5. It will then ask you to confirm the passphrase.
  6. Your key will be generated.

To view your SSH public key on Windows

  1. Run the command:
    type ~\.ssh\id_rsa.pub

    Where USERNAME is the name of your user.

  2. The command will display your SSH public key.
  3. Now, use the Ctrl+C keyboard shortcut to copy the contents of the file.

You can also do something similar to what we did on macOS (copying the SSH public key directly to the clipboard).

To copy the SSH public key on Windows

  1. Issue the command:
    type ~\.ssh\id_rsa.pub | clip

    Where USERNAME is your username.

  2. Now, paste that key on a word processor or wherever you need it.

How to view your private key

Chances are, you’re never going to 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:

  1. Remove the public key from the authorized_keys file on every server that uses the key pair.
  2. Delete the public and private keys on the host.
  3. Generate a new key pair.
  4. Send the new key pair to the servers you need to log in to with SSH key authentication.

If you leave any trace of that compromised key pair on any server or desktop, you run the risk of allowing someone access.

Subscribe to the Cybersecurity Insider Newsletter

Strengthen your organization's IT security defenses by keeping abreast of the latest cybersecurity news, solutions, and best practices. Delivered every Monday, Tuesday and Thursday

Subscribe to the Cybersecurity Insider Newsletter

Strengthen your organization's IT security defenses by keeping abreast of the latest cybersecurity news, solutions, and best practices. Delivered every Monday, Tuesday and Thursday

Also Read

How to View Your SSH Keys in Linux, macOS and Windows | TechRepublic (2024)

References

Top Articles
How to unlock Vexcalibur & The Variable Exotic quest - Destiny 2
Destiny 2 'Avalon' Exotic mission guide: How to get Vexcalibur
Spasa Parish
Rentals for rent in Maastricht
159R Bus Schedule Pdf
Sallisaw Bin Store
Black Adam Showtimes Near Maya Cinemas Delano
Espn Transfer Portal Basketball
Pollen Levels Richmond
11 Best Sites Like The Chive For Funny Pictures and Memes
Things to do in Wichita Falls on weekends 12-15 September
Craigslist Pets Huntsville Alabama
Paulette Goddard | American Actress, Modern Times, Charlie Chaplin
Red Dead Redemption 2 Legendary Fish Locations Guide (“A Fisher of Fish”)
What's the Difference Between Halal and Haram Meat & Food?
R/Skinwalker
Rugged Gentleman Barber Shop Martinsburg Wv
Jennifer Lenzini Leaving Ktiv
Justified - Streams, Episodenguide und News zur Serie
Epay. Medstarhealth.org
Olde Kegg Bar & Grill Portage Menu
Cubilabras
Half Inning In Which The Home Team Bats Crossword
Amazing Lash Bay Colony
Juego Friv Poki
Dirt Devil Ud70181 Parts Diagram
Truist Bank Open Saturday
Water Leaks in Your Car When It Rains? Common Causes & Fixes
What’s Closing at Disney World? A Complete Guide
New from Simply So Good - Cherry Apricot Slab Pie
Drys Pharmacy
modelo julia - PLAYBOARD
Poker News Views Gossip
Abby's Caribbean Cafe
Joanna Gaines Reveals Who Bought the 'Fixer Upper' Lake House and Her Favorite Features of the Milestone Project
Tri-State Dog Racing Results
Navy Qrs Supervisor Answers
Trade Chart Dave Richard
Lincoln Financial Field Section 110
Free Stuff Craigslist Roanoke Va
Wi Dept Of Regulation & Licensing
Pick N Pull Near Me [Locator Map + Guide + FAQ]
Crystal Westbrooks Nipple
Ice Hockey Dboard
Über 60 Prozent Rabatt auf E-Bikes: Aldi reduziert sämtliche Pedelecs stark im Preis - nur noch für kurze Zeit
Wie blocke ich einen Bot aus Boardman/USA - sellerforum.de
Infinity Pool Showtimes Near Maya Cinemas Bakersfield
Dermpathdiagnostics Com Pay Invoice
How To Use Price Chopper Points At Quiktrip
Maria Butina Bikini
Busted Newspaper Zapata Tx
Latest Posts
Article information

Author: Fr. Dewey Fisher

Last Updated:

Views: 6454

Rating: 4.1 / 5 (62 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Fr. Dewey Fisher

Birthday: 1993-03-26

Address: 917 Hyun Views, Rogahnmouth, KY 91013-8827

Phone: +5938540192553

Job: Administration Developer

Hobby: Embroidery, Horseback riding, Juggling, Urban exploration, Skiing, Cycling, Handball

Introduction: My name is Fr. Dewey Fisher, I am a powerful, open, faithful, combative, spotless, faithful, fair person who loves writing and wants to share my knowledge and understanding with you.