News for hackers. Stuff that matters.
Re:whoarethey: Determine Who Can Log in to an SSH Server by user3939382 on Tuesday January 10, 2023 @07:28PM (#34333457)
I don’t reuse the same keys everywhere so this wouldn’t work. Is that normal to reuse your keys like that?
Re:whoarethey: Determine Who Can Log in to an SSH Server by agwa on Tuesday January 10, 2023 @07:38PM (#34333521)
If by "reuse" you mean having one key per client and using it with multiple servers, then yes, that is very common and being able to do that is arguably the entire point of public key cryptography. If you use a distinct key for every client-server pair you give up a lot of convenience and it becomes very difficult to use hardware-backed keys.
Re:whoarethey: Determine Who Can Log in to an SSH Server by enasterosophes on Tuesday January 10, 2023 @09:41PM (#34334425)
Not disagreeing with you, but I can think of two reasons why you might use distinct keys from the one client (and use ssh config to enforce the separation)

* You want to present different identities to the world and don't want them being conflated, eg separate your github hobby projects from your employer organization.

* You are using ssh certificate authentication, which isn't supported by GitHub yet, but you might be using it for other things, and GitHub should hopefully support it in the future. Since this relies on the name of the cert file matching the private key filename (eg id_ed25519-cert.pub corresponding to id_ed25519), you can't afaik have different certs active for the one key. Personally, I deal with this by simply having different private keys for different purposes, to avoid cert collision.

Re:whoarethey: Determine Who Can Log in to an SSH Server by psanford on Tuesday January 10, 2023 @09:54PM (#34334505)
github does support ssh certs, but only for its enterprise offering.
Re:whoarethey: Determine Who Can Log in to an SSH Server by enasterosophes on Tuesday January 10, 2023 @09:56PM (#34334520)
Interesting, thanks. I had a feeling the support was limited to host certs.
Re:whoarethey: Determine Who Can Log in to an SSH Server by chasil on Wednesday January 11, 2023 @02:22AM (#34335988)
In any case, "sed -i" can be used to add new keys, and remove old ones, from a set of ~/.ssh/authorized_keys files on a collection of hosts.

It is good to be aware of the contents of these allowed credentials, and sweep unused entries. This article has a script that automates the procedure:

https://www.linuxjournal.com/content/ssh-key-rotation-posix-...

Re:whoarethey: Determine Who Can Log in to an SSH Server by tialaramex on Wednesday January 11, 2023 @03:55AM (#34336503)
I'm guessing Andrew knows this, but for anybody else, in the particular case of Security Keys, they're specifically designed to create fresh public/private key pairs for each enrolment, exactly because of the privacy aspect. If you use your iPhone's fingerprint sensor to sign into both Facebook and GitHub not only do Meta and Microsoft not get the fingerprint, they don't even get a way to correlate these identities, they both just get the very minimum we could achieve, proof you are you still, whoever that is.
Re:whoarethey: Determine Who Can Log in to an SSH Server by andreareina on Wednesday January 11, 2023 @09:19AM (#34338733)
There are many points to public key cryptography. The important ones enable new capabilities, e.g. communicating with a counterparty that I’ve never met. But it also comes with downsides as you’ve documented.

Generating a new key pair is a moment of work and eliminates many of those problems.

Re:whoarethey: Determine Who Can Log in to an SSH Server by blakesterz on Tuesday January 10, 2023 @08:41PM (#34333988)
Good question. It's so easy to set up .ssh/config and use a unique key per host I would think most people using SSH would be doing that? I don't know how common that is I guess.
Re:whoarethey: Determine Who Can Log in to an SSH Server by GauntletWizard on Tuesday January 10, 2023 @08:46PM (#34334046)
I don't, and I don't suggest people do. Opsec on who controls your servers is compromised in a million other ways if you're a legit business, and even if it's important to hide, there's other low-hanging fruit.

That said, if I had any servers I controlled with other online identities, setting up keys for those identities would be sane, and if I valued privacy over convenience it's not that hard of a tradeoff. But I set up my new machines by typing in my github username to authorize all the pubkeys in there, and for the most part update my old machines the same way - curl -O https://github.com/gauntletwizard.keys ; vimdiff .ssh/authorized_keys gauntletwizard.keys

Re:whoarethey: Determine Who Can Log in to an SSH Server by KronisLV on Wednesday January 11, 2023 @05:38AM (#34337042)
Example for anyone not familiar.

Command line option:

  ssh -i ~/.ssh/key1 [email protected]
Configuration option (.ssh/config):

  Host example.com
    User user
    IdentityFile ~/.ssh/key1
Random blog post that summarizes it: https://www.systutorials.com/how-to-choose-the-key-used-by-s...

Curiously, the ssh.com (a more expected search result) docs aren't as useful: https://www.ssh.com/academy/ssh/config

  Host
  
  Restricts the following declarations to be only for those hosts that match one of the patterns given after the keyword. The pattern is matched against the host name given on the command line.
It's cool that there's a sane description there, but what about examples?

Slightly more in depth examples, in case anyone is curious about what other options there are: https://linuxize.com/post/using-the-ssh-config-file/

> Good question. It's so easy to set up .ssh/config and use a unique key per host I would think most people using SSH would be doing that? I don't know how common that is I guess.

Because of the above, I'd say that it's not common because it's not documented in a discoverable enough way, or doesn't have enough examples - it appears that people don't care enough. If we wanted something else to be the case, then most tutorials on how to use SSH (say, the kind that people might stumble upon in DigialOcean's tutorials or whatever your search engine of choice might prioritize for a given query) should include this as an additional section.

Re:whoarethey: Determine Who Can Log in to an SSH Server by user3939382 on Wednesday January 11, 2023 @11:40AM (#34340468)
This is why I don't reuse keys. I setup the config like this for every host and in fact, I then set a bash alias like

  alias example='ssh example.com'
It's no inconvenience for me, it's rare I'm setting up a new box so adding it to my config convention isn't a big deal.
Re:whoarethey: Determine Who Can Log in to an SSH Server by doublepg23 on Tuesday January 10, 2023 @08:59PM (#34334150)
I’ve been reusing the same rsa4096 for about five years after an abortive attempt to use a ed25519 key.
Re:whoarethey: Determine Who Can Log in to an SSH Server by keyczar931 on Tuesday January 10, 2023 @09:45PM (#34334453)
The "normal" way is to have one keypair per device you use (unless using a key on a USB stick or something like that) and use that key for everything you do from that device (private, professional, etc.)

The key identifies you physically (not as an employee, open source contributor or whatever, specifically). And the reason for having different ones in different devices is that it's more secure to generate on each device without leaking it during transfer.

This way you can revoke the keys per device (e.g. you lose your laptop or have it stolen, revoke the key user@laptop and not the one user@university-lab).

I use the same passphrase everywhere (but, again, they're different keys).