imrehg, to random
@imrehg@fosstodon.org avatar

This happens when I'm thinking more of the tools of the trade, in preparation of actually doing the trade.

https://gergely.imreh.net/blog/2024/05/git-login-and-commit-signing-with-security/

gergely, to ArtificialIntelligence

Git login and commit signing with security

Doing software engineering (well-ish) is pretty hard to imagine without working in version control, which most of the time means git. In a practical setup of git there’s the question of how do I get access to the code it stores — how do I “check things out”? — and optionally how can others verify that it was indeed me who did the changes — how do I “sign” my commits? Recently I’ve changed my mind about what’s a good combination for these two aspects, and what tools am I using to do them.

Access Options

In broad terms git repositories can be checked out either though the HTTP protocol, or through the SSH protocol. Both have pros and cons.

Having two-factor authentication (2FA) made the HTTP access more secure but also more setup (no more direct username/password usage, rather needing to create extra access keys used in place of passwords). Credentials were still in plain text (as far as I know) on the machine in some git config files.

The SSH setup was in some sense more practical one (creating keys on your own machine, and just passing in the public key portion), though there were still secrets in plain text on my machine (as I don’t think the majority of people used password-protected SSH keys, due to their user experience). This is what I’ve used for years: add a new SSH key for a new machine that I’m working on, check code out through ssh+git, and work away.

When I’ve recently came across the git-credential-manager tool that supposed to make HTTP access nicer (for various git servers and services), and get rid of plain text secrets. Of course this is not the first or only one of the tools that does git credentials, but being made by GitHub, it had some more clout. This made me re-evaulate what options do I have for SSH as well for similar security improvements.

Thus I’ve found that both 1Password and KeePassXC (the two main password managers I use) have ssh-agent integration, and thus can store SSH keys + give access to them as needed. No more plain text (or password protected) private keys on disk with these either!

Now it seems there are two good, new options to evaulate, and for the full picture I looked at how the code signing options work in this context as well.

Code Signing Options

When signing my commits to authenticate authorship, it’s possible to use PGP/GPG (the “classic way”), or now also SSH keys (as detailed, for example here or here).

The GPG setup is well established, and also links my commits to my identities used elsewhere (e.g. signed emails sent to mailing lists that care about it, with the key linked from this site’s frontpage). This of course is not always needed or desired, but it decouples the identity from the code hosting platform. There’s some serious downsides as well, though: GPG signing keys are not supposed to be numerous (just a single one), and thus if I use multiple machines to work on, I will have to take my private keys with me between machines, for example making copies of them. Or if not making copies, then have them on hardware keys (that have other problems with backups and all that, if I got it right the last time I tried to understand the process).

The SSH key commit signing is much newer (need git version at least 2.34), but it’s also simpler: add a key to my git hosting service, sign commits with that key, and thus the service can match things up and show that match. I can add as many keys as machines I’m working on if needed, no need to transfer or copy keys between machines, and I can also choose use some keys for login only or code signing only.

A third party trying to verify these signatures, though, would need to get the keys from the hosting service (I’d find it surprising if people would distribute their commit signing keys out of band the same way as they do with GPG public keys, since there are likely more of them). Hence it git hosting services will need to make the user’s keys available (as they do at the relevant username.keys URLs, e.g. mine on GitHub and GitLab).

Also can’t forget to add the relevant keys to the list of allowed signing keys locally, and all the other relevant setup (see e.g. the GitHub and GitLab docs). There are a bit too many places to update, but it’s mostly set-it-and-forget-it. After that, once started to sign commits, adding the --show-signatures flag to the commands that support it (git log, git show for example), should show the signatures.

My Winning Combo

Looking at the opions above, there’s a matrix of options that we can use, and here’s what I think about them:

GPG signature SSH key signature
Git Credential Helper Extra setup Simpler
SSH clone The usual Most convenience 👍

Convenience matrix of Git access (rows) and commit signing (columns) optionsReally, where I want to be is just SSH keys for everything, even if they are imperfect, but they have the most number of puzzle pieces to fit.

SSH Key Security

While previously SSH keys were really just held as files in your ~/.ssh folder, most likely, recently I’ve found (tada!) that the password managers I use can also store & serve SSH keys: see in particular 1Password’s SSH documentation and KeePassXC docs (scroll to SSH Agent Integration on that page), though I’m sure other password managers can do this too.

1Password

The two password managers listed above handle things quite similarly. 1Password is a bit less hands-on, though, the default settings work pretty well.

https://gergely.imreh.net/blog/wp-content/uploads/2024/04/Screenshot-2024-04-27-at-11.55.43.pngOne important bit is that 1Password runs its own SSH agent, so that has to be configured in the relevant places, but it’s easy enough. The approvals are also useful, so it’s more transparent when something accesses the key.

1Password pop-up for SSH key usage1Password pop-up for SSH key usage

With this things generally work, and relatively easy to reason about things. When things are less clear, it might be just a debug check-away away from seeing the keys added to this alternate agent:

$ export SSH_AUTH_SOCK=~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock<br></br>$ ssh-add -l<br></br>256 SHA256:XfRsbxRMm+CN[...snip...]

KeePassXC

KeePassXC, being open source, is my preferred solution of the two, though unsurprisingly it’s the more awkward one to set up. The main differences from 1Password include:

  • needing to generate the keys externally to the password manager (rather than having built-in ssh keygen) – this is a con on usability but a strong pro on basing security on the established tool, rather than potentially questionably reimplement it
  • uses the main SSH agent, so no extra setup is necessary in most of the tools – this is a potential pro on usability for configurations, but a potential con that the worflow and config of loading keys into the agent needs a bit more understanding to be both ergonomic and safe to one’s level of paranoia
  • the key use confirmation defaults to “ok” on pressing Enter on the pop-up (rather than Cancel) – this is a pro on usability, but con on “failing open” rather than closed

SSH key usage confirmation with KeePassXCSSH key usage confirmation with KeePassXC

It’s still a pretty simple workflow, and it’s quite interesting to see how many things KeePassXC learned to do as well.

Experience

Thinking about the various threat models to my SSH crendentials, this setup adds one more layer to the defence in depth, and it does feel more relaxed already (relaxed from a point of stress I didn’t quite know I had before).

Picking the SSH key based login and signing feels like using the most appropriate tech for the moment, and there are still knobs for people to adapt it to their security levels (different SSH keys for login and signing, passwords on the keys themselves, etc…)

This setup works very well when I want to be notified whenever a tool’s using the SSH key so it would be more obvious if a stray process is trying, say exiltrate the keys. On the other hand this breaks down when git itself is running background processes, such as git-maintenance, so that’s not something that I could use here. So far out of (literally) thousands of codebases & repos I’ve used that maintenance setup exactly once, for convenience. For me it is not a major loss, then.

The one bit that feels a step backwards is that having the SSH keys in the password manager and carrying it around counteracts the “separate key for each system” arrangement. This might just be part of getting used to new processes, and not an actual downside.

Further Thoughts

In cybersecurity yesterday’s best practices might be inadecvate today and “last week’s” practices might be outright dangerous… Gonna keep revisiting this setup more broadly and in terms of details, as I learn more.

It’s a good question why even do code signing (besides having a “verified” check mark, which alone doesn’t mean much if not part of a verification process), though this needs some more space to unpack. For the time being I’ll assume that signing is better than not signing, if nothing else than as a forward looking prep for better audit processes down the line.

There’s really a question around having too many things in a single password manager: nowadays it can be the complete “royal flush” of password, TOTP, SSH key, recovery codes, passkey… and likely more bits that I might not be using yet? This does make me uneasy, and likely a scale on which usability and security will adjust over time (such as. bundling and unbundling various cybersecurity aspects).

I might also actually misunderstand various things above, if so, I’d be very keen to hear, just drop me a line!

Original post: https://gergely.imreh.net/blog/2024/05/git-login-and-commit-signing-with-security/

image/png
1Password pop-up for SSH key usage

1977er, to iPad German
@1977er@23.social avatar

Terminalprogramme für sessions auf dem . Gibts da brauchbare Lösungen, die die Verbindung im Hintergrund halten können?

nblr,
@nblr@chaos.social avatar

@1977er Nee. Geht ja prinzipbedingt nicht. Bin bei termius und mosh gelandet, vor allem weil das in der Lage ist, Keys im secure enclave zu erzeugen und nicht nur welche zu importieren.

adfichter, (edited ) to opensource German
@adfichter@chaos.social avatar

Wer ist "Jia Tan"? Eine interessant zu lesende Spurensuche von
@marcel anhand von technischen Indizien zu Zeitzonen, Verhalten, Motive, Aufwand.

https://dnip.ch/2024/05/14/spurensuche-jia-tan-xz/

JLW_the_Jobber, to random
@JLW_the_Jobber@fosstodon.org avatar

I just want to into all the things just to do

:mastodon_oops:

adamsdesk,
@adamsdesk@fosstodon.org avatar

@JLW_the_Jobber It's geeat software, but unfortunately its no longer being developed. https://www.adamsdesk.com/posts/neofetch-archive-goodbye/

textovervideo, to python
@textovervideo@fosstodon.org avatar

pyinfra turns Python code into shell commands and runs them on your servers. Execute ad-hoc commands and write declarative operations. Target SSH servers, local machine and Docker containers. Fast and scales from one server to thousands.

https://pyinfra.com/

lovisix, to random French
@lovisix@social.zdx.fr avatar

Hi foks,

Is there any specialist of ?

I install it on a computer at home.
Here in holidays I can see it with tailscale status. I also see it as connected machine on the web gui tailscale.

But I can't to it.

I can't remembrer if I enabled on my .

Help will be really appreciate.
Thanks in advance.

davidbisset, to coffee
@davidbisset@phpc.social avatar

New startup sells through... SSH?

https://www.terminal.shop/

br00t4c, to random
@br00t4c@mastodon.social avatar

The next step up for high-impact identity authorization

https://go.theregister.com/feed/www.theregister.com/2024/04/29/the_next_step_up_for/

brokenix, to random

Endlessh is an tarpit that very slowly sends an endless, random SSH banner. It keeps SSH clients locked up for hours or even days at a time. The purpose is to put your real SSH server on another port and then let the script kiddies get stuck in this tarpit instead of bothering a real server.
https://github.com/skeeto/endlessh

mdrights, to RaspberryPi
@mdrights@fosstodon.org avatar

Forgot to toot, I had tried to use to run graphic applications on my servers ( , and even a broken-screen with Wayland !)

After some configuration all of them work. Yay I can now run x11 apps on headless machines.

premartinpatrick, to security French
@premartinpatrick@mastouille.fr avatar

Mettez à jour Putty, Filezilla, TortoiseGit et WinSCP si vous utilisez des clés SSH pour vous connecter à certains serveurs (dans l'idéal faites aussi la mise à jour si vous n'êtes pas concerné).
https://www.programmez.com/node/36392

abcdw, to hosting
@abcdw@fosstodon.org avatar

Found a cool SSH Apps project:
https://pico.sh/

Static sites, RSS feed to email digest, reverse ssh tunnels (for exposing local socket with public domain name), blog engine, pastebin and couple more.

All available via ssh/rsync.

fell, to sysadmin
@fell@ma.fellr.net avatar

On my machines, I have begun to disable SSH on IPv4 and replaced it with a tarpit instead. :drgn_comfy_evil:

mforester,
@mforester@rollenspiel.social avatar

@fell yeah, that's the thing. I definitely need to change the port instead.
I also have my firewall limited to specific IP ranges, so technically I should be fine, but I'd like to slow people down. 😁

fell,
@fell@ma.fellr.net avatar

@mforester Unfortunately, the bots seem smarter than I thought. Most of them only stay for a few seconds. :(

pitrh, to security
@pitrh@mastodon.social avatar

Fun Facts About the April 2024 Cisco Attack Data https://nxdomain.no/~peter/fun_facts_about_the_april_2024_cisco_attach_data.html (or with trackers https://bsdly.blogspot.com/2024/04/fun-facts-about-april-2024-cisco-attack.html) - light analysis of attack data by yours truly (again for the morning CE(S)T crowd)

  • All
  • Subscribed
  • Moderated
  • Favorites
  • tester
  • thenastyranch
  • magazineikmin
  • khanakhh
  • Youngstown
  • mdbf
  • Durango
  • slotface
  • GTA5RPClips
  • ngwrru68w68
  • rosin
  • kavyap
  • osvaldo12
  • InstantRegret
  • JUstTest
  • DreamBathrooms
  • anitta
  • Leos
  • normalnudes
  • cubers
  • ethstaker
  • tacticalgear
  • everett
  • megavids
  • provamag3
  • modclub
  • cisconetworking
  • lostlight
  • All magazines