How to Find Unencrypted SSH Keys and Encrypt Them (2024)

View Other Checks How to Find Unencrypted SSH Keys and Encrypt Them (1)

SSH keys are commonly used to sign into servers, push code, and verifyidentities. It's important they are password-protected.

What Are SSH Keys?

An SSH Key is a two part (public and private key) cryptographic token which isprimarily used to facilitate remote secure shell (SSH) access to a computer.

In practice SSH Keys are used to sign in to servers, authenticate to remoterepositories like Github, and as a way of verifying the authenticity offiles and messages.

How Do SSH Keys End Up Unencrypted?

Engineers and other technical users need to semi-frequently generate new SSHkeys to authenticate to various services. To do that they often generatethe SSH key pair via the terminal by running the following command:

$ ssh-keygen -t ed25519 -C "first.name@example.com"

During the process they will eventually be asked to set a passphrase witha prompt that looks like the following:

> Enter passphrase (empty for no passphrase): [Type a passphrase]

Unfortunately, this portion of the process can be easily skipped by simplypressing the enter key on the keyboard. If this portion of the processis skipped the private key can be used by anyone who can get possession ofthe file.

Why do developers skip this step? There are a few reasons that come up in practice:

  • Ignorance - Many developers don’t know there is any security value in adding apassphrase to an SSH key.

  • Perceived Lack of Necessity - Many SSH keys are generated under the assumptionthey won’t be used to obtain access to anything important and thus adding a passphraseis unnecessary overkill.

  • Convenience - By adding a passphrase, developers often assume they will needto constantly enter a passphrase every time they push code to GitHub or accessa commonly used server. By forgoing the password they don’t have to contendwith any productivity loss.

While these arguments drive the behavior, none of them are strong. In fact,a lot of the perceived downsides of using an encrypted key can be mitigatedwith modern tools.

For example, on macOS if an encrypted SSH key is accessed by a process, youwill be automatically prompted to enter the passphrase and then you can chooseto save it in the keychain.

Locating Unencrypted SSH Keys with Osquery

Osquery (an open-source tool for querying the state of the OS) is capable oflocating user SSH keys across devices. It does this by tapping into thessh-agent on the device and looking for them in common locations on the primarydisk like ~./ssh.

Osquery uses SQL to query the system’s current state. Here is an example of aSQL query that can detect all unencrypted SSH keys on disk.

SELECT path FROM user_ssh_keys WHERE encrypted = 0;

Kolide extends osquery’s functionality with additional data like MD5 fingerprintand automatically stores metadata about keys in its built-in Inventory. This allows you to detect things like duplicate SSH keys across devices.

How Do I Encrypt an Unencrypted SSH Key?

Encrypting a pre-existing SSH key is a trivial process. On Mac or Linuxsimply:

  1. Make note of the private SSH key you wish to encrypt. For this example, let’s assume it’s in /Users/user/.ssh/id_rsa
  2. Open the terminal
  3. Type ssh-keygen -p -f /Users/user/.ssh/id_rsa and press enter

You will be prompted to create a passphrase. We suggest you create a uniquepassphrase per key and store those passphrases in a secure/approved passwordmanager like 1Password.

You may not see text being entered as you type your password in. Do not worry,this is normal security feature of the terminal and it is receiving your keystrokes.

This problem cannot be remediated through traditional automation with tools like an MDM. You need to be able to stop devices that fail this check form authenticating to your SaaS apps and then give end-users precise instructions on how to unblock their device.

Kolide's Okta Integration does exactly that. Onece integrated in your sign-in flow, Kolide will automatically associate devices with your users' Okta identities. From there, it can block any device that exhibits this problem and then provide the user, step-by-step instructions on how to fix it. Once fixed, Kolide immediately unblocks their device. Watch a demo to find out more.

How to Find Unencrypted SSH Keys and Encrypt Them (2024)
Top Articles
DigiCert_BestPractices_8-919
Credit Card Processing Fees: How Do They Work? | Capital One
SZA: Weinen und töten und alles dazwischen
Xre-02022
Where are the Best Boxing Gyms in the UK? - JD Sports
Cold Air Intake - High-flow, Roto-mold Tube - TOYOTA TACOMA V6-4.0
Top Scorers Transfermarkt
Math Playground Protractor
The Idol - watch tv show streaming online
Moviesda Dubbed Tamil Movies
GAY (and stinky) DOGS [scat] by Entomb
Craigslist Deming
Rhinotimes
Love In The Air Ep 9 Eng Sub Dailymotion
How Much Are Tb Tests At Cvs
Les Rainwater Auto Sales
Gem City Surgeons Miami Valley South
Tamilyogi Proxy
Everything you need to know about Costco Travel (and why I love it) - The Points Guy
Mychart Anmed Health Login
Invitation Homes plans to spend $1 billion buying houses in an already overheated market. Here's its presentation to investors setting out its playbook.
Bjerrum difference plots - Big Chemical Encyclopedia
Soulstone Survivors Igg
Zillow Group Stock Price | ZG Stock Quote, News, and History | Markets Insider
1 Filmy4Wap In
Defending The Broken Isles
Nk 1399
Mikayla Campinos: Unveiling The Truth Behind The Leaked Content
Claio Rotisserie Menu
The Powers Below Drop Rate
Uncovering the Enigmatic Trish Stratus: From Net Worth to Personal Life
Nacogdoches, Texas: Step Back in Time in Texas' Oldest Town
Cbs Trade Value Chart Week 10
Skroch Funeral Home
Netherforged Lavaproof Boots
Cvb Location Code Lookup
Samsung 9C8
How Much Is Mink V3
Avance Primary Care Morrisville
Space Marine 2 Error Code 4: Connection Lost [Solved]
SF bay area cars & trucks "chevrolet 50" - craigslist
Collier Urgent Care Park Shore
The Transformation Of Vanessa Ray From Childhood To Blue Bloods - Looper
Wilson Tattoo Shops
Juiced Banned Ad
Mynord
Playboi Carti Heardle
Sam's Club Gas Price Sioux City
Bank Of America Appointments Near Me
2121 Gateway Point
Jasgotgass2
Haunted Mansion Showtimes Near The Grand 14 - Ambassador
Latest Posts
Article information

Author: Dean Jakubowski Ret

Last Updated:

Views: 5538

Rating: 5 / 5 (70 voted)

Reviews: 85% of readers found this page helpful

Author information

Name: Dean Jakubowski Ret

Birthday: 1996-05-10

Address: Apt. 425 4346 Santiago Islands, Shariside, AK 38830-1874

Phone: +96313309894162

Job: Legacy Sales Designer

Hobby: Baseball, Wood carving, Candle making, Jigsaw puzzles, Lacemaking, Parkour, Drawing

Introduction: My name is Dean Jakubowski Ret, I am a enthusiastic, friendly, homely, handsome, zealous, brainy, elegant person who loves writing and wants to share my knowledge and understanding with you.