Live data from Hacker News

A sane SSH(1) key management example

try.popho.be

1–10 of 69 posts

Re: A sane SSH(1) key management example

#2
Really like the approach here. In the past, I've typically managed my SSH keys by naming them as id_ like so, then tinkering with the ssh_config to make use of them.

Never thought of using the token approach, though, definitely makes things simpler to work with.

Re: A sane SSH(1) key management example

#3
> How would you look at someone using a single key for their car, house, safe, work place, and so on?

This is a terrible analogy, and I don't see any other justification for this setup.

An SSH "key" is also referred to as an "identity". Contrary to a car key, it is not tied to the car, but to the client's identity. It is more like a badge than a brass key.

A car key has the limitation that your lock can only accept one key, and can't be easily updated to accept/refuse keys. You also can't remotely give somebody access (you have to hand them the key) and you can't prevent someone with the key from making a copy without returning it.

An SSH key pair has none of those limitations so it's really not clear why anyone might want to manage them like car keys. If anything, the root password is more like a car key than a key pair is.

Re: A sane SSH(1) key management example

#5
post #4

> Did you know that ssh sends all your public keys to any server it tries to authenticate to? Never really thought about it. Feels kind of "leaky", even if necessary.

Not a big deal at all considering that they're public keys, there's no security concern there.

Feels weird, but it's like going into a building that requires a badge and showing proof that you actually own several keys, then the building guard telling you he needs X key to enter since that's the one they know, and it's authorized.

All your public keys in your GitHub account are accessible through a link, just .keys>

Re: A sane SSH(1) key management example

#6
> It’s common knowledge that you shouldn’t put all your eggs in the same basket, but most of the time on IRC or on reddit (or the Internet at large, really), I see people using one single ssh key for all uses. How would you look at someone using a single key for their car, house, safe, work place, and so on?

a bit envious tbh. I would be so annoyed if we would get a key fob for every door at work instead of one key fob that can be reprogrammed.

The comparison drawn here is bad because you would look at the person funny because "How the hell is someone able to replace every lock so that this works?"

At work we have a script that pulls all our gitlab keys and adds them to the authorized_keys section if you should have access to a server. In what scenario is leaking your identity over ssh really a problem? If I want to connect to a server normally I either own or administrate the server. Next use case is a leaked private key.... How the hell do you leak your private key? There are 3 scenarios I can think of:

  * you copy it to a host/usb drive and someone else has access to it
  * a new attack is found to generate a private key to your public key
  * someone gets access to your machine and steals it
1) you shouldn't do 2) leaves all your keys vulnerable 3) every key on the machine needs to be replaced

> As an added benefit now, if one of your ssh keys ever leaks, there’s only one place to remove it from ~/.ssh/authorized_keys (where the login@hostname comment is still present).

Do you do this for every machine you own? Sounds like a real pain. Maybe only because of my setup with passwords and keepassxc.

If you fear leaking your key maybe a fido2 device and/or password would be a better solution. Don't get me wrong I too have more than one ssh key, but this seems overly excessive. Since this solutions looks rather clean it maybe isn't, but I don't see many advantages here. But it is a nice setup nonetheless. I could reasonably easy implement something like this on top of my existing setup, but right now it seems only to add more administrative work. Especially since I really like the idea of an asymmetric key that opens my doors. The only downside for ssh keys is that you can't invalidate them in a central location.

Re: A sane SSH(1) key management example

#7
post #2

Really like the approach here. In the past, I've typically managed my SSH keys by naming them as id_ like so, then tinkering with the ssh_config to make use of them. Never thought of using the token approach, though, definitely makes things simpler to work with.

The config file already does this, this is just a shortcut with %h and the file system structure.

You literally start an entry with "Host " follwed by "User" and "IdentifyFile". There's even a bash autocomplete rule for it so you can tab through your servers "ssh ". It won't send all the keys to the server if you organize this way (which doesn't really matter anyway, since they are PUBLIC KEYS).

It resolves to a preference: using a file or the OS filesystem to organize your keys.

Re: A sane SSH(1) key management example

#9
post #4

> Did you know that ssh sends all your public keys to any server it tries to authenticate to? Never really thought about it. Feels kind of "leaky", even if necessary.

Not a big deal at all considering that they're public keys, there's no security concern there. Feels weird, but it's like going into a building that requires a badge and showing proof that you actually own several keys, then the building guard telling you he needs X key to enter since that's the one they know, and it's authorized. All your public keys in your GitHub account are accessible through a link, just .keys>

As well as .keys, there's .gpg for GPG keys, and .png for the profile picture.

Re: A sane SSH(1) key management example

#10

> It’s common knowledge that you shouldn’t put all your eggs in the same basket, but most of the time on IRC or on reddit (or the Internet at large, really), I see people using one single ssh key for all uses. How would you look at someone using a single key for their car, house, safe, work place, and so on? a bit envious tbh. I would be so annoyed if we would get a key fob for every door at work instead of one key f…

Yeah, I would entirely love it if I could use the same key for everything I have that takes a key. That'd be great. As it is I just don't bother with keys for, like, back doors to my house and such. They're in a drawer somewhere and never get used. I just can't enter those doors from outside, if they're locked.

One key (well, I mean, I'd want copies of it) for everything would be excellent.

Terrible analogy because I'd look at them like "damn, they've got it figured out!"

[EDIT] Thinking further, the only way this falls apart is if I want to give someone else a key to just one thing, but that's a non-issue with ssh, so the analogy is still comically backwards. "But what if someone gets ahold of one key! Same key for everything, that's access to all your stuff!" well shit man, that's about the same as getting one of them if they're all different, in most cases—where do you think I keep my extra keys? And the couple I carry, so are likely to get in someone else's hands by accident or whatever, are the "give you the kingdom" type anyway. Get my car key, you can get in my house (garage door opener). Get any house key, you can probably get in my car, plus the rest of my keys (e.g. safe) are in there because I don't carry them around all the time.

Yeah, letting someone borrow a key is the only time this might be inconvenient, and again, that's not a factor with SSH.

Post reply on HN