whoarethey: Determine Who Can Log in to an SSH Server
agwa.name
agwa.name
ssh whoami.filippo.io - https://news.ycombinator.com/item?id=34301768 - Jan 2023 (79 comments)
* 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.
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-...
Generating a new key pair is a moment of work and eliminates many of those problems.
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
Command line option:
ssh -i ~/.ssh/key1 user@example.com
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.
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.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).
In practice I have used metasploit's `auxiliary/scanner/ssh/ssh_login_pubkey` to do this: https://www.rapid7.com/db/modules/auxiliary/scanner/ssh/ssh_...
But standalone tools are always handy!
(Edited to add a better URL) (Second edit: I linked the wrong module here see my comment below for the correct one.)
Key-based authentication for SSH is often referred to as "pubkey authentication" (because you share your public key with the server) so that's probably where the title comes from. I don't think it exploits the same problem.
Edit: here is the right module: `auxiliary/scanner/ssh/ssh_identify_pubkeys`, it is sort of nice in that you can give it a range of usernames, pubkeys, and hosts and it will try all combinations, and can be routed through your meterpreter pivots: https://www.rapid7.com/db/modules/auxiliary/scanner/ssh/ssh_...
Does it have any purpose?
Having a public register of public keys makes it easy to give people access to your organization, CI/CD etc.
There are cryptographic protocols where public keys are kept private. For example TLS with client certificates (the client's certificate gets sent encrypted to the server). Ditto SSHv2 (the client need not reveal all its public keys, and it does get to authenticate the server before revealing its identity and public keys).
Hmm... I was under the impression that up until TLS 1.3 the client cert was sent in the clear during session negotiation...
That's a very strong overstatement. With this argument, you could argue that data leaks involving names, emails, etc are fine, because emails and names are meant to be public.
Not a big deal, but I forgot about that leak, so "expose" made me read further and be reminded that clearly I am not a blackhat, or any color hat for that matter.
Your average devops person? They will be happy when given a kubeconfig file linked to a role allowing them "kubectl exec" access to the workloads.
IdentitiesOnly yes
IdentityFile ~/.ssh/github_keyUntil then... I guess just throw wireguard in front of everything.....
WireGuard does really well here, where an authentication failure is indistinguishable from no WireGuard service at all.