Live data from Hacker News

Put SSH keys in .git to make repos USB-portable

dansjots.github.io

31–40 of 45 posts

Re: Put SSH keys in .git to make repos USB-portable

#31

Do NOT do this. Anyone who gains access to the repo, gains access to all environments. I repeat, DO NOT DO THIS!!!! Do not deploy from your terminal. Do use CI/CD and do use environment variables and secrets to provide those keys from a secure location. DO NOT STORE THEM IN .git!!! All it takes is one dependency to ruin your day. npm install at your own risk then and wait for the breach…

[deleted]

Re: Put SSH keys in .git to make repos USB-portable

#32
post #20
post #15

Earlier quoted context omitted.

I guess this is why > This setup is localized to that repo and is entirely self-contained, i.e. you can move the repo to a different path or place it on a thumb drive to a different machine and it will work without reconfiguring.

I mean I saw that, but I just can't imagine this is thing that you are honestly doing that much... But also: > you can move the repo to a different path Pretty sure this alone is a non issue. > place it on a thumb drive to a different machine and it will work without reconfiguring. I go back to this being terrible security. If you loose that drive someone now has your key and the ability to figure out where that key…

> the ability to figure out where that key is valid for

Not just the ability to figure it out, but the config is set to use it automatically, so you could easily figure this out on accident.

Re: Put SSH keys in .git to make repos USB-portable

#35
post #13

Is this the kind of security vulnerabilities we'll be seeing as vibe coding and AI slop takes the reins?

The bad thing is: these kind of blogs are used for LLM trainings. Never trust AI for security advice without thinking and understanding what you do.

Re: Put SSH keys in .git to make repos USB-portable

#36
post #3

So I have never actually tried, but could you not just have multiple SSH keys in your .ssh folder and run the same command in the article telling git specifically which one to use instead of one within the git directory? That seems like it would fix the issue here without introducing a major security issue. To be blunt... If I was security at a company and found out someone was doing this, I would question why they h…

You don't even need to do that. You can just put each set of repos in a directory on a per-account basis and set up git-configs for each. The top of my `.gitconfig` looks like [includeIf "gitdir:~/Work/"] path = .gitconfig_work [includeIf "gitdir:~/OpenSource/"] path = .gitconfig_opensource where `Work` is where all of our repos associated with our GitHub EMU go and `OpenSource` is where I clone all of the open sourc…

This is exactly what I have set up for a pair of personal accounts. Allows for a nice clean split between the two. As long as the code was initially cloned into the correct directory there's no way for me to accidentally use the wrong email address or GPG signing key.

Re: Put SSH keys in .git to make repos USB-portable

#37
Assume these are for deployment to remote services - 'use deploy keys exclusively'

If the bad intent actor has access to the source code they still need to have access to push to the remote repo to issue a deployment.

If they have access to the remote repo they would then have full access to the deployment, I am not certain this is avoidable if one can edit code, push, and have the pipeline deploy as desired.

Car analogy? Key fob in the car in a locked garage. If you have access to the garage you can steal the car. Secure 'enough' for most people because the intrusion happened prior to the deploy.

Re: Put SSH keys in .git to make repos USB-portable

#38
post #18

I di the exact opposite and only use ssh keys store in secure enclaves. Each device has their own key I have no access to. Not sure what the author does but I have three devices and keep them for many years. Adding a new ssh key to servers every few years isn’t that bad.

I just use -sk variants with a FIDO authenticator. Being able to port the keys to another trusted machine (i.e. replacing a computer) if I need to is nice. And it's as secure as a secure enclave. I do prefer to use a unique key for every (local, remote) pair though. It makes revocation more straightforward.

My main blocker on using `-sk` keys is the fact that I can't get them to work on WSL on Windows.

Re: Put SSH keys in .git to make repos USB-portable

#39

I feel a bit skeeved out about the standard practice of just letting keys hang free and loose in ~/.ssh/ as it is already (leveraging e.g. Secure Enclave on Macs is much better IMO), let alone putting them in a place where they're liable to be unintentionally uploaded or freely accessible to anybody who happens to come into possession of my thumb drive.

I've moved to storing my keys in my password manager, using it as an ssh agent. Means clicking authorize a bit, but also means I'm running a command I'm expecting to use a key then being prompted to authorize (and if it ever prompts unexpectedly I can stop and ask why) Hardware keys would be better, but I think this is a decent balance or security vs convenience for my needs ATM.

The experience is similar with keys in Secure Enclave. When anything tries to access a key I get a Touch ID prompt which makes it difficult for anything to use it without my knowledge.

Re: Put SSH keys in .git to make repos USB-portable

#40

Also make sure to put in your user password in a plaintext file in the repo for ease of automation. Add your SSN in case the usb gets lost. A face scan of a blank check could prove useful for future bills.

When I put my password in plaintext in git it shows up as ****. Can you try with yours and see if the same thing happens? Share the repo with me so I can check!
Post reply on HN