lemmy.sean.land
  • Communities
  • Multi-communities
  • Support Lemmy
  • Search
  • Login
  • Sign Up
Selfhosted@lemmy.worldbytaco_shale032@lemmy.ml
4 days

You can't afford to keep your SSH keys on disk

jola.dev English

cross-posted from: https://lemmy.bestiver.se/post/1462999

Comments

35
    You can't afford to keep your SSH keys on disk | jola.dev
    jola.dev
    Why you want to delete your SSH keys from disk, and how to use Bitwarden's SSH agent to do it.
    You must log in or register to comment.

    • SavvyWolf@pawb.socialEnglish
      4 days

      To just make this absolutely clear, this means that the private keys are vulnerable to be exiltrated by malicious code scanning my disk.

      If you have malicious code capable of scanning your disk it’s basically game over anyway. They can intercept your passwords and ssh connection no matter what you do.

      What’s the security model here? An app that gets user account access but gives it up if it can’t find exactly ssh keys?

        • HubertManne@piefed.socialEnglish
          4 days

          Yeah its like the stuff where if a person has acees to the machine its vulnerable.

          • cow@lemmy.worldEnglish
            3 days

            What’s the security model here? An app that gets user account access but gives it up if it can’t find exactly ssh keys?

            My guess is that a malicious package is scanning your home directory for stuff like SSH keys, GPG keys, AWS keys, etc. It would have filesystem access permission already in the MacOS sandbox due to running inside a common interpreter like node or python, but it might be restricted from stuff like attaching to other processes memory, where it could just get the keys out of bitwarden.

            Could also just be obscurity as most infostealers are programmed to grab keys from common locations and not many developers use bitwarden for keys.

            If you want something resistant to a fully compromised system you need to use something hardware backed, whether an external key or an internal secure enclave.

            • femtek@lemmy.blahaj.zoneEnglish
              4 days

              I get it when you have multiple servers, a few of the recent attacks admins had tokens and ssh keys that had access to other things. But for a homelab with one server that has admin to everything anyway. Not much use.

            • Mordikan@kbin.earth
              4 days

              So, instead of hosting your own SSH keys, you have a 3rd party host your SSH keys?

                • KairuByte@lemmy.dbzer0.comEnglish
                  4 days

                  No, memorize them and type them in by hand every time you need them.

                    • SpatchyIsOnline@lemmy.worldEnglish
                      4 days

                      Hmm… Almost like some kind of… password? 🤔

                      • Alvaro@lemmy.blahaj.zoneEnglish
                        3 days

                        So the meat cloud?

                        • ede1998@troet.cafe
                          4 days

                          @KairuByte @Mordikan that’s what i did when working at eMudhra. Just gotta make sure the key is easy to memorize, like 4.
                          /s

                            • Mordikan@kbin.earth
                              3 days

                              You know we didn’t have these problems back in the days of telnet. We were all just out there raw dogging our passwords in clear text.

                            • cow@lemmy.worldEnglish
                              3 days

                              There’s people who memorize their 20 or 30 word cryptocurrency seeds. There’s no reason someone couldn’t memorize an ssh key if you encoded it as words. Still not very practical though.

                              • Reannlegge@lemmy.caEnglish
                                4 days

                                A 256 RSA key eh? Sure no problem.

                                • Zwuzelmaus@feddit.orgEnglish
                                  4 days

                                  This is the way.

                                • bhhaskin@lemmy.bitsofsimplicity.comEnglish
                                  4 days

                                  Yeah if you are really concerned then use a yubikey or smart card.

                                    • i_am_not_a_robot@discuss.tchncs.deEnglish
                                      4 days

                                      I’ve never tried it, but another option is ssh-tpm-agent or tpm2-pkcs11. Basically they use the TPM as a non-removable smart card, which is free and potentially more secure than a regular smart card because a smart card can’t normally verify the integrity of the OS that is talking to it. If you’re connecting from a Mac, Apple’s system is called Secure Enclave.

                                        • jj4211@lemmy.worldEnglish
                                          3 days

                                          However the “non removable” part gets you back to being susceptible to malware. If you are afraid malware can read your disk, then malware can further submit signing requests to any online ssh key mechanism.

                                          So having a removable device at least means you know beyond any shadow of a doubt that not only is your key credibly protected, but use of your key is outright impossible when not plugged in.

                                      • taco_shale032@lemmy.mlEnglish
                                        4 days

                                        You can self host Bitwarden, which is what I assumed most people in this community do.

                                        I’m not entirely sure why this got downvoted, it’s not a terrible idea to put your keys in your password manager rather than leave them on disk in plain text.

                                          • i_am_not_a_robot@discuss.tchncs.deEnglish
                                            4 days

                                            Normally if people are worried they store their keys encrypted on disk and use ssh-agent. Putting them in Bitwarden is a little less secure because you’re distributing the encrypted files to more places and likely decrypting them on multiple devices. But it is convenient.

                                            • rako@tarte.nuage-libre.frFrançais
                                              4 days

                                              The title is misleading. There’s no problem with keeping ssh private keys on disk, there’s a problem with keeping private keys in cleartext. OpenSSH keys are always encrypted on your disk, unless you have no passphrase, which is just stupid and the very first thing you must solve.

                                              Once you have a passphrase there is no problem. Of course don’t store the passphrase on disk, store it… in your password manager.

                                              Your post is a solution to a problem that doesn’t exist and is a result of a lack of knowledge. Yet the blog post.

                                                • taco_shale032@lemmy.mlEnglish
                                                  4 days

                                                  Thanks for explaining.

                                            • Kethal@lemmy.worldEnglish
                                              4 days

                                              This doesn’t seem any different from encrypting them and using an ssh agent.

                                                • taco_shale032@lemmy.mlEnglish
                                                  4 days

                                                  I think that’s exactly what a password manager would do essentially, just in a user friendlier way.

                                                    • lucas@startrek.websiteEnglish
                                                      4 days

                                                      How could it possibly be more user friendly than what is already and completely seamlessly integrated into the typical SSH flow?

                                                        • jj4211@lemmy.worldEnglish
                                                          3 days

                                                          So it’s super easy for me day to day, I log in and my login password also drives add to the ssh agent.

                                                          However, ssh-keygen and ssh-add and setting all that up is gasp a command line process and you actively have to search up how to do it.

                                                          Password managers offer gui driving the oblivious user to do the same thing.

                                                          I much prefer my way, but I would be tempted to indicate a password manager application if I’m having to tell someone else how to do it, especially in Windows where I don’t think you can integrate it as nicely.

                                                            • lucas@startrek.websiteEnglish
                                                              3 days

                                                              But SSH is already a command line tool? Besides, the guide in the article itself includes several steps of configuration (most likely in the command line) to set this agent up. I don’t really understand what ‘command-line process’ supposedly needs actively searching how to do it? Is it really that hard to remember (or tab-complete) ssh-keygen then follow interactive prompts?

                                                              I feel like maybe I’m missing something here, and I’m not saying there can’t be reasons to do this, but I’m not following any ‘simplicity’ angle, given that all it’s doing is adding extra steps.

                                                      • silenium_dev@feddit.orgEnglish
                                                        4 days

                                                        Just use a password-protected private key?

                                                          • ExLisper@lemmy.curiana.netEnglish
                                                            3 days

                                                            And type a password when I ssh to my servers? Like some caveman?

                                                              • jj4211@lemmy.worldEnglish
                                                                3 days

                                                                You use ssh-agent and ssh-add to take the passphrase hit once, then on disk copy is protected and it is mostly password less.

                                                                Mine unlocks with PAM, so on login without additional step.

                                                                  • silenium_dev@feddit.orgEnglish
                                                                    3 days

                                                                    Even better, put the passphrase into your keyring (which is password-protected with your login password by default on most DEs) and set your keyring as the default askpass provider

                                                                    Or the most secure of all, use a physical passkey/smartcard like a Yubikey or Nitrokey

                                                                    • ExLisper@lemmy.curiana.netEnglish
                                                                      3 days

                                                                      Interesting… I will add that to my TODO list.

                                                                    • sem@lemmy.blahaj.zoneEnglish
                                                                      3 days

                                                                      A password manager can paste for you automatically

                                                                    • redballooon@lemmy.worldEnglish
                                                                      3 days

                                                                      How then can we write a scandalizing article?

                                                                        • silenium_dev@feddit.orgEnglish
                                                                          3 days

                                                                          Oh shit, totally forgot about that. Yeah, then that’s definitely the worst solution ever, and we must write an article, no, multiple articles about how insecure SSH keys are!!!1!1!1!1!!

                                                                      • Venia Silente@lemmy.dbzer0.comEnglish
                                                                        4 days

                                                                        Using something like Bitwarden? Why not just pass?

                                                                        Also a good note on the “panic”, sometimes when I read these articles they read like this:

                                                                        You can’t keep your SSH keys on disk! It’s unsafe! Give them to Huang, or the competition will!

                                                                        • Reannlegge@lemmy.caEnglish
                                                                          4 days

                                                                          All of the things I ssh into have keys, there is no way I am trusting anything without keys. There is no way I am remembering a 256 bit RSA encrypted key or sharing it with any one who does not need it. I change the ssh port when I am first setting something new up on my network, typically before I do anything else.

                                                                          There are only two things on my network with port 22 open, the first one sounds kinda wrong but it is my firewall, but it is open so that things can get to a vLAN that has a pi zero 2 on it acting as a honey pot.

                                                                          Selfhosted@lemmy.world

                                                                          selfhosted@lemmy.world

                                                                          Subscribe from remote instance

                                                                          Create postModlog
                                                                          You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !selfhosted@lemmy.world

                                                                          Report community

                                                                          A place to share alternatives to popular online services that can be self-hosted without giving up privacy or locking you into a service you don’t control.

                                                                          Rules:

                                                                          Detailed Rules Post

                                                                          1. Be civil.

                                                                          2. No spam.

                                                                          3. Posts are to be related to self-hosting.

                                                                          4. Don’t duplicate the full text of your blog or readme if you’re providing a link.

                                                                          5. Submission headline should match the article title.

                                                                          6. No trolling.

                                                                          7. Promotion posts require active participation, with an account that is at least 30 days old. F/LOSS without a paywall has exceptions, with requirements. See the rules link for details. Tags [CBH] or [AIP] are required, see the links in Rule 8 for details.

                                                                          8. AI-related discussions and AI-involved promotional posts have additional requirements for tagging, as noted in Rule 7 and the AI & Promotional Post Expanded Rules post, and find example disclosures here.

                                                                          Resources:

                                                                          • selfh.st Newsletter and index of selfhosted software and apps
                                                                          • awesome-selfhosted software
                                                                          • awesome-sysadmin resources
                                                                          • Self-Hosted Podcast from Jupiter Broadcasting

                                                                          Any issues on the community? Report it using the report flag.

                                                                          Questions? DM the mods!

                                                                          Visibility: Public

                                                                          This community is visible to everyone.

                                                                          695 users / Day2.94K users / Week3.01K users / Month3.03K users / 6 months115 posts1.57K comments1 local subscriber64.1K subscribers
                                                                          Mods: Ruud@lemmy.world
                                                                          • UI: -nightly-2026-11-26
                                                                          • BE: 1.0.0-nightly-2026-11-26
                                                                          • Modlog
                                                                          • Legal
                                                                          • Instances
                                                                          • Docs
                                                                          • Code
                                                                          • join-lemmy.org