r/github • • 18d ago

Discussion Do you use a passphrase on your SSH keys?

I am building an app that interacts with local SSH keys and trying to decide how much time to invest in edge-case ssh-agent support. So I wonder how many people do use the passphrase for ssh keys?

85 Upvotes

58 comments sorted by

26

u/pdath 18d ago

I use a passphrase on an older SSH key, but my newer keys have been moved to hardware YubiKeys.

I shifted to Yubikey because it needs a physical touch, which an AI agent can't do, yet.

5

u/Jou_See 18d ago

Makes sense, I have been thinking about getting one for some time.

6

u/burgerg 18d ago

You can also configure them with no-touch-required. I always have a nano plugged in which requires touch, but I have some no-touch-required ssh keys on my 5C key, which I then plugin as well for when I have to bulk update stuff using Ansible

2

u/Happy_Breakfast7965 18d ago

I'm curious, how do you organize SSH keys on a hardware Yubikey? Do you have personal and work separate? Do you have more than 1-2?

6

u/pdath 18d ago

I have 5 YubiKeys.

I have an offline GPG master key. From that, I have a signing key stored on a YubiKey.
When I am developing code, I put it inside a git branch. I allow AI to commit as often as it likes in that branch. When I am happy and have reviewed the code, I squash-merge it into main and sign it with my GPG key. Because the GPG keys need a touch, only a human can sign the commit.

This is an example of a recent commit. Can you see that it says "Verified" on the right-hand side? If you click on the "Verified" button, you can confirm it was signed by my GPG key. If you see that, you know I personally reviewed and authorised it.
https://github.com/pdath/bmf/commits/main/

I personally have two YubiKeys, a primary and a backup. I have my SSH key on those. I also have a *lot* of passkeys stored on those, used for logging into many websites.

Each time an AI agent wants to SSH to one of my machines, it has to get my approval by touching the YubiKey.

And then, as you hinted, I have a pair of YubiKeys for work, main and backup. Those mostly have passkeys stored on them for sure access to work resources.

2

u/pqu 16d ago

I use my ssh keys for signing commits nowadays, I’m a bit sick of gpg

1

u/MBILC 18d ago

interesting work flow, I am always looking at ways to improve security for our developers, might have to dig into this more...

2

u/pdath 18d ago

I don't want to say too much in public in case I expose myself to risk, but my general goal is to have no private keys stored on any machine.

Then, if your machine does get compromised, the scope of what can be impacted is greatly limited.

I also use SSH key authentication for things like GitHub repos for git operations, rather than "api" keys.

2

u/MBILC 18d ago

This is how I am, anything that can be used with a Yubikey, is on a yubikey with backups and pins / password enforced, along with touch for everything.

Never thought to extended it to SSH keys and such.

2

u/pdath 18d ago

I have a feeling I know what your doing this weekend. :-)

2

u/MBILC 18d ago

shhh, don't tell the wife! ;)

1

u/bastardoperator 18d ago

Why aren't you using SSH keys to sign your commits? There's no need for GPG on GitHub anymore. Even commits made through GitHub's web UI get a "Verified" badge without requiring your own SSH or GPG keys. SSH signing is simpler, especially if you're already using hardware-backed SSH keys. You've added a bunch of complexity for no obvious benefit.

1

u/pdath 18d ago

Some open source projects I work on prefer them to signing with SSH. And I've you have it setup, it is just as easy to continue.

However, if I was starting again, I woukd lean more heavily towards SSH signing.

2

u/davy_jones_locket 18d ago

There are some things I keep on a separate yubikey, like root admin credentials. Or when I worked for government, credentials that needed to be specifically separate from other credentials.

Other work credentials I don't mind mixing with my personal credentials on the hardware. 

17

u/SouthCollar2929 18d ago

You're not getting a representative sample here

3

u/Jou_See 18d ago

In what way?

6

u/Motor-Concentrate788 18d ago

At first i did, but then after a while it gets tedious having to open my password manager just to ssh so i removed the passphrase. My reasoning being if someone stole my laptop, full disk encryption would protect the key anyway. And if malware somehow got into my laptop and stole my key files, it could probably still extract my keys from ssh-agent.

1

u/Jou_See 18d ago

yea, that makes sense

3

u/bartoque 18d ago

Then a whole world might open up for you wrg to the usage of an ssh agent. You only type the passphrase once, as long that session remains available.

For example on Windows when using Putty, use the accompanying tool Pageant. In my case at login a Start Up script runs Pageant prompting for the passwords of all keys being loaded by it.

On linux I use Keychain as a wrapper around ssh-agent.

https://wiki.gentoo.org/wiki/Keychain/en https://github.com/danielrobbins/keychain

1

u/dankmolot 18d ago

Unfortunately for example some programs in NixOS space which use ssh keys do not support ssh-agent

1

u/OstrobogulousIntent 17d ago

I just use a simpler password I can remember - the real protection is the key - the simpler passphrase just gives that slight bit extra without too much friction - but I get where you're coming from

54

u/mbround18 18d ago

Every time, at its core the ssh key gives you access to systems and code. I also use a physical security key ed25519-sk & gpg with password for code signing. Does it get tedious? Yes haha but its worth it

11

u/Chouni-Rhasaan 18d ago

100% agree, especially with code signing in the mix. A leaked unencrypted key is a nightmare scenario

3

u/nicksuperb 18d ago edited 18d ago

I’ve been using these for a long time. I honestly wish it was easier to use (especially for non-technical folks) but it can be a genuine pain in the ass for the uninitiated. I’m on macOS and the smart card integration with yubikey is how I do login/admin auth. I also store passkeys and use a root certificate to generate ssh keys all on my yubikey. No keyring necessary. It’s a good feeling to know I could nuke my laptop and walk away unscathed.

Edit: In regard to op’s question, no passwords necessary. Look into certificate auth for ssh and never look back. It’s been a part of the spec for some time now

Edit 2: When I actually need real passwords (i.e. master passwords, keepass xc, tomb, etc) Look at DiceKeys for physical password security that is dead simple. DiceKeys.com. API keys and other temporary things go into Secure Enclave.

1

u/desuburinga 16d ago

Absolutely life changing for me, I went full FIDO2, better than having to type out a password every time.

1

u/ReasonCurrent8941 15d ago

That's a solid approach. Using both passphrase protection and a hardware security key covers a good range of potential compromises. It certainly adds steps, but the security gained is substantial.

0

u/XYMYX 18d ago

Im just a beginner and i use a ssh key.

19

u/pconwell 18d ago

I am sure I'm in the minority here and I recognize it's not a good idea, but I do not. 

7

u/Soapy-Cilantro 18d ago edited 18d ago

There are only a few situations where a passphrase is going to really protect you, but it's mostly just protecting the key at rest on disk. As others have said, proper malware can extract your keys from ssh agent, or a keylogger could snag the passphrase if typed out. If an infostealer just scrapes ~.ssh/ then the passphrase will help.

The better thing to do is to use FIDO2 hardware like yubikey or nitrokey. IMO it's not tedious once it's a part of your workflow and the default habit.

1

u/Atmosck 18d ago

Wouldn't you like to know?

3

u/jonwolski 18d ago

Yes, and I use ssh-agent along with MacOS’ keychain support (ssh-add -k $KEY_FILE), so that I never have to type the password. In fact, my ssh config has BatchMode yes, so that I get errors instead of prompts.

2

u/j0x7be 18d ago

Pretty much always. I use a password manager that adds keys to agents.

2

u/MarsupialLeast145 18d ago

Yes, and no.

2

u/runnercola 16d ago

No because most of my ssh keys are “sk” keys now.

1

u/ridobe 18d ago

I use a simple passphrase and a yubikey.

1

u/countnfight 18d ago

Yes. I have one set of keys for everyday things that use a passphrase that I know, so it's not in any password managers. I have a separate key for other things that requires a Yubikey with touch.

1

u/shgysk8zer0 18d ago

I use Secritive on Mac. My key is stored in Secure Enclave. So technically no, but it's more secure because of how it's stored and the biometrics to access it.

1

u/nakfil 18d ago

No because I used 1Password’s SSH integration so the keys aren’t even stored on disk.

1

u/DominusGod 17d ago

Technically, they’re stored on disk but encrypted

1

u/nakfil 17d ago

True, I should have said they aren’t stored in plain text on disk

1

u/Current-Ant-9047 18d ago

If you have MacBook with Touch ID just use Secretive and keep your SSH key there. It uses security enclave, ask AI to learn more about this 

1

u/enigmamonkey 18d ago edited 18d ago

I definitely do, but I'll qualify...

Since I'm not sure what you're building: What do you mean by "edge-case" and when you say "passphrase", is the password length important in your situation? I presume not but asking just in case it matters.

For me using an SSH agent itself isn't an edge case at all since I believe it should be standard practice. So, when building an app that is somehow impacted by that, my opinion is that you aught to take it into account.

p.s. I'm saying this since technically having a password in your SSH key doesn't necessitate the use of an SSH agent, but not having an SSH agent results in you being required to manually type your password repeatedly, both on local systems and on remote systems if you don't use agent key forwarding (e.g. if you SSH to yet another server). The SSH agent merely stores the decrypted key it for you in memory (avoiding storing an unencrypted key at rest) and handles handshakes for you once you've provided your password.

1

u/JVAV00 18d ago

Depends, check this vid first and see if you are one of them using this setup: https://youtu.be/NGWwUQWzpIc

1

u/Connir 18d ago

Yes and an agent.

1

u/mbsp5 17d ago

Bitwarden with an ssh agent and forwarding. Works flawlessly once setup. It’s only decrypted after you use biometrics.

1

u/Poat540 17d ago

Nope, my home pi’s do, work don’t care

1

u/yiyufromthe216 17d ago

It only makes sense if you don't have full disk encryption.  Most of people have the agent socket set it up anyway at login, so it's the same as you unlocking the encrypted partition once at boot time

1

u/0kth4t5fin3 17d ago

what even the fuck absolutely of course

1

u/lugpocalypse 17d ago

My ssh keys are in 1password. Also, ssh agent is your friend. But, for work and professionally its all ssh certificates. No long lived creds that could leak.

1

u/chalbersma 17d ago

Support ssh-agent

1

u/AdDirect6138 16d ago

La clef ssh est ouverte avec un mot de passe très fort uniquement avec mon ip, si je dois me connecté sur une autre ip il demande un 2FA supplémentaire, c'est pas parfait mais c'est toujours mieux que rien

1

u/ConsonantEcho 7d ago

For a GUI, the case I’d test is the user coming back after a restart: the repo is still there, but their key isn’t loaded in the agent. A useful error tells them “your key is locked or not loaded” instead of sending them down the “do I even have access to this repo?” rabbit hole.

1

u/tblancher 18d ago

I unlock mine with systemd+TPM2 when I log into my laptop.

0

u/CollegeElectricalKid 18d ago

This is underrated advice. We did exactly this and realized two of our top three jobs could be handled by Slack’s built-in workflows. We only needed an AI tool for answering repeat questions. Saved us from paying for an expensive platform we’d have used 20 percent of.

0

u/ShogiOne 18d ago

I am developing a project that helps to see exactly this: https://github.com/suelio/guardrail-code