Put SSH keys in .git to make repos USB-portable
dansjots.github.io·1d·
Discuss: Hacker News
📂Git
Preview
Report Post

2025-12-11

My repository remotes are set up to use deploy keys exclusively, as I don’t want to inadvertently push changes from the wrong account due to forgetting to change the local machine user’s credentials.

I used to do so by keeping several subdirectories inside my .ssh directory for per-account keys and manually pasting them outside whenever I want to push a specific repo, but it’s cumbersome and still quite error-prone.

Eventually I came across this SuperUser answer and adapted it with my slight twist leveraging the fact that the .git directory’s contents are well-behaved and don’t read or modify anything that Git doesn’t recognize, so no risk of accidentally committing keys.

–…

Similar Posts

Loading similar posts...