13 ms·
Poll HN: Do you use SSH certificates (not mere public-key authentication)?
Do you use SSH certificates for work and/or personal SSH logins?
I have just switched, for my personal machines, but dealing with the CA keys is a royal pain.
What on earth do people to do keep their CA keys accessible but secure?
(You can choose multiple options below)
- lkuty 4y agoInfos about how to use them would be great.
- jeroenhd 4y agoI find this quick introduction to be quite helpful if you want to learn the basics: https://jameshfisher.com/2018/03/16/how-to-create-an-ssh-certificate-authority/ https://jameshfisher.com/2018/03/16/how-to-create-an-ssh-cer... If you don't know about them, you can probably answer "no" in this poll :)
- traceroute66 4y agoSee the link I just posted in my reply, i.e. https://smallstep.com/blog/diy-single-sign-on-for-ssh/ https://smallstep.com/blog/diy-single-sign-on-for-ssh/
- jeroenhd 4y agoEdit: parent comment got corrected. Old comment left below for reference. Note that this is a blog about X509 certificates, not SSH certificates! That blog page does link to https://smallstep.com/blog/diy-single-sign-on-for-ssh/ https://smallstep.com/blog/diy-single-sign-on-for-ssh/ which is about SSH certificates.
- traceroute66 4y ago@jeroenhd Mea-culpa, had a choice of two smallstep bookmarks and I copy/pasted the wrong one ! Now corrected.
- traceroute66 4y agoI've used public-key basically forever. I have wanted to go that step further and implement certificates for a good few years now, I absolutely see the value, no question about it (i.e. no more out of date authorized_keys files, no need to even install authorized_keys files in the first place, the list goes on). I wish YubiKeys were more flexible in allowing SSH certificates to be hosted on them (currently can only host X509 type). Because if I could use a Yubi for SSH certificate signing I would have already been using certificates ! (Yes I know, theoretically you can do it with GPG keys, but frankly that's a PITA with many issues). My current plan is to take inspiration from this : https://smallstep.com/blog/diy-single-sign-on-for-ssh/ https://smallstep.com/blog/diy-single-sign-on-for-ssh/
- jeroenhd 4y agoYou can use this great-but-also-terrible system to do X509 certificate validation with SSH: https://github.com/mjg59/ssh_pki https://github.com/mjg59/ssh_pki Maybe after some deeper security analysis this idea could help you work around the limitations of Yubikey's hardware. However, if the author of a piece of security software tells me something is a bad idea, I tend to accept that, especially if that author is mjg59.
- traceroute66 4y ago@jeroenhd Mea-culpa, had a choice of two smallstep bookmarks and I copy/pasted the wrong one ! Now corrected.
- XiS 4y agoAs an alternative, you might consider using an ed25519-sk ssh key so you can use your YubiKey as a second factor during authentication. I've got my keys loaded up in the SSH agent by KeepassXC when I open my database and can log in to a box just by pressing my YubiKey. No keys on disk, no passwords to remember (except your Keepass master key ofcourse).
- tomaslaureano 4y agoWould love to know more about this workflow!
- ultra_nick 4y agoWhat's the difference between a certificate and a public/private keys?
- tfigment 4y agoYou add the intermediate key to config for trust. You do not need authorized_keys files for each user. Good for team and central management and faster key rotation but then needs trusted intermediate authority which is secure. No password or key rotation on machine itself which is good if you have a lot of machines.
- sofixa 4y agoCertificate is short lived and signed on the fly for when you need it. The server trusts your SSH CA, and you can ask it to sign any private key you want, with a ttl. So you get extra security (credentials are dynamic and short -lived, and also per-user if needed) and lower maintenance because you only have the SSH CA public key to setup on all machines and that one needs less rotation/updates than public keys.
- hawski 4y agoBut then don't you need to maintain this CA certificate? I guess it makes sense for wider centralized access.
- thayne 4y agoA certificate doesn't necessarily have to be short lived, although in practice they usually are. The main difference is that with an ssh key, you install the public key directly on the target host. With a certificate, you Just tell the host to trust a CA, and use that CA to sign client certificates.
- goodpoint 4y ago> lower maintenance because you only have the SSH CA public key to setup on all machines This is hardly "lower maintenance" than pushing updates to the authorized_keys across servers. Or having servers poll for such file.
- jeroenhd 4y agoI've set them up for both identification and authorization with most of my virtual machines. I've set up two CAs (one for server identification, one for client identification) and provision virtual machines to trust the client authorization certificate by default. I still need to work something out for setting up server identification automatically but I haven't had the time (or interest) to find out how to set proper random hostnames through cloudinit scripts. I think the certificate system is especially great for certificate login from multiple devices. At some point I was just constantly copying/updating authorized_keys files and with SSH certificates I can just provision my clients once and the problem is solved, assuming I use the same username everywhere. On the server side it's kind of annoying to set up right because there's no easy process like ACME for SSH certificates. Depending on how much effort I want to put into (temporary) virtual machines I'll either TOFU the host certificate or go through the effort to properly sign it if I have easy access to the CA key from the device I'm working on.
- lstoll 4y agoWe use an AWS KMS asymmetric key for the CA keys, they're cheap and avoids exposing the private key material in an any way. For signing SSH certificates, we run a small service (prototype code dump at https://github.com/pardot/sshsigner https://github.com/pardot/sshsigner) that uses this key to sign short lived certificates. Auth to the service is via OIDC issued ID tokens. On the client side we have a custom SSH agent that uses an ephemeral in-memory private key. The agent manages the OIDC web flow and calling out to the service for signing on demand. This lets us keep the cert duration small and scoped, and allows us to force re-auth for sudo etc. via the web flow. We also do a similar thing for host keys, IAM auth the instances and sign certificates. Altogether works well, provides a nice user experience, and keeps long-lived/leakable creds out of out environment.
- yrro 4y agoI use Kerberos (KDC hands out TGT only after MFA)
- jerf 4y agoWe looked into them once at work for our "conventional" SSH infrastructure, but immediately rammed into the wall that a certificate can sign a key, but you can't have a full PKI infrastructure like SSL where certs can sign certs that can sign keys. Without the ability to delegate, the logistics of needing to create an absolutely centralized authority to do the useful things we wanted to do within the organization raised the cost of "first value" too high for us to fuss over. So for large-ish organizations (~1000 affected employees) we had a hard time justifying any effort put into it versus the established infrastructures for key management that already exist. On the other side, as a personal user of SSH with basically one person to worry about, the effort of setting up a certificate seems like just a waste versus the existing key-based infrastructure; I don't understand at all what attack it would prevent or what convenience it would provide for the cost of learning it. A general principle is you get good at what you do a lot, and you aren't good at what you do rarely. Key-based management has its issues, but people have been doing it for a while and they're good at it. Not necessarily "great" and not necessarily "unable to be improved", but they're good at it. People understand it and know how to use it. Nobody uses certificates, so nobody understands how they work or what to do with them, and they have the weakness I cited above. So, even though in a perfect world certificates may be superior, in the world we live in now, the competition between the existing polished infrastructure for pure key-based management is pretty good, even if you think it's a polished turd, and the infrastructure for SSH certs is pretty bad, even if you think it's an uncut diamond in the rough. It's difficult to look at that situation and honestly choose to proceed with the certificates. As others point out, the cloud services are proceeding in other directions as well which will probably continue to make using SSH certificates directly a very difficult choice to practically justify.
- gunapologist99 4y agoI agree. We use a distributed Userify infrastructure to take some of the sting out of key management for our teams; this gives us the ability to tie user authentication into our enterprise directory but still delegate an entire Userify infrastructure on a BU basis, which is pretty awesome. To your point about clouds making it more difficult in the future, it's becoming more challenging to scale the CA across auto scaling groups with dynamic IPs and where you can't control TXT records. We've found that SSH keys are very flexible, and we simply needed a centralized management point (which we have now), but with decentralized operation in case anything is offline along the way. Also, it's very important to us to be able to kill active sessions globally when a user is removed, and there doesn't seem to be any other tools that do that except Userify.
- xaduha 4y agoI recently got SmartCard HSM (also available as Nitrokey HSM 1 and 2 I think), but didn't get around to setting it up yet. For personal use it does seem like an overkill, when FIDO2 security keys are much more convenient.
- derefr 4y agoIf you use Google Cloud’s “OS Login” feature, you’re using (semi-ephemeral) SSH certificates.
- dotwaffle 4y agoI store my authorized_keys in DNS TXT records, that are DNSSEC signed, with a validating resolver on the box. I then just use "/usr/bin/hesinfo %u ssh" as my AuthorizedKeysCommand in OpenSSH. I wrote a little tool that allowed you to "#include" other DNS records etc, but "hesinfo" is generally easily installable/available so it's just easier.
- aliqot 4y agoIs there some way I can purchase you a pint?
- dotwaffle 4y agoIt would be rude of me to decline such an offer ;)
- bshep 4y agoI would love a HOWTO link. Also, can the DNS server be public facing? Any issues with the authorized keys being public (AFAICT there isnt but i am not a security expert)?
- theblazehen 4y agoThere are none. In fact yours is already public: https://github.com/bshep.keys https://github.com/bshep.keys
- bombcar 4y agoThere is technically one minor one, which really isn't one - but you should be aware of. Someone can take your authorized keys and add them to a box they control, and trick you into logging in. However, this would trigger the "new host" warning SSH gives you, and you can minimize this by minimizing which hosts you allow your private keys to be used on. And if someone is so actively trying to attack you they probably have more direct methods available.
- nsheridan 4y agoI use them for personal machines, and have deployed them in the past in work environments. A few years ago I wrote a CA which can exchange oauth tokens for signed keys: https://github.com/nsheridan/cashier https://github.com/nsheridan/cashier Auth is handled in a browser e.g. by Google, and the CA will sign a key and return a cert with a valid token.
- deleted 4y ago[deleted]
- GekkePrutser 4y agoI use private keys but store them on a Yubikey. In OpenPGP format, not using Fido2 at present. I use OpenPGP for other stuff too like my password manager so I'm not ready to move to fido. But certificates - no. I don't see the need for this in my home environment. In my opinion it only makes sense if you have a PKI, in which case you already have the whole CA scenario covered.
- baybal2 4y ago
- blueflow 4y agoI use certificates to deal with the n clients -> m servers i have privately. On some machines i have AuthorizedPrincipalsFile include my username, so i can directly login as root there. I found these SSH features while studying the ssh-keygen(1) man page. I don't use extra tools aside what SSH ships.
- dingosity 4y agoI did for a while, then didn't because neither my chromebook nor my android devices supported them. Then they did and now I do again.
- Joel_Mckay 4y agoHypothetically, SSH over SSL/TLS or an iodine tunnel along with a few IDS tripwires. Every approach has strengths and weaknesses, the password-less method is convenient... but is the number one target for worms/bots. =)
- Ottolay 4y agoI use public/private with the private key handled by Yubikey PIV functionality.
- vngzs 4y agoDoing this without something like Vault is very difficult. Vault is designed to provide similar guarantees to an HSM (it's a service designed to make keys usable but not exfiltratable), and that's essential for any long-lived certificates.
- tptacek 4y agoI don't know that I disagree with the broader point here, but long-lived certificates are what you don't want.
- goodpoint 4y agoVault is not able to provide guarantees similar to an HSM.
- vngzs 4y agoYou're right - an adversary with physical access to machines running Vault can steal keys from it. An HSM is designed to survive at least temporary physical access by an adversary. And if you have management infrastructure that lets admins access the servers running Vault, then they can exfiltrate the keys (an HSM can be configured to prevent this). There exist threats that HSMs will stop that Vault simply won't stop. But they are both systems intended to provide secure storage of key material with policy-based access to that key material. As an SSH CA, you can configure Vault to sign SSH pubkeys but never divulge the key material. Depending on your threat model, it might get you what you want for this use-case, but you should definitely be aware of the limitations of Vault's security model.
- ninefathom 4y agoBearing in mind that, on principle, I never expose ssh to untrusted hosts/networks, for many years my solution for ssh-SSO was GSSAPI. Typically this would be a two part auth, where gssapi-kex had to succeed, _and_ the connecting user had to supply the kerberos password on the server side via PAM/keyboard-interactive to reduce the risk of "sysadmin walked away and left screen unlocked." I think this approach has fallen out of favour these days compared to PKI, but I haven't been an enterprise sysadmin in a few years. Edit: for those curious, ephemeral access in this case is easily enough managed via e.g. the usual AD-on-*nix methods. It doesn't scale beyond a few dozen systems, but the scenario described above was back before scale-out became the fashion.
- StewardMcOy 4y agoI don't see the benefit of using certificates for personal use. In my mind, certificates only really shine when administering a fleet of servers in a large company, as it eliminates the need to update the authorized_keys file on every server someone is hired or leaves. I could be missing some less obvious use cases, but if you're just authenticating to your personal machines, it doesn't seem worth it. It's not any more secure than SSH keys, and you have to also manage and secure your CA key.
- stormbrew 4y agoI think this is true if you only really have one or two computers you use ssh from regularly but if you have a few or you get new ones frequently you can get back to that experience of not having to frequently generate and distribute public keys by using a yubikey to sign local keys and then your authorized_keys only needs the cert authorization in it.
- NjU24E48YqdBGnG 4y agoI just store my SSH key in my Yubikey and then I can SSH from any computer that has SSH and GPG installed. Gets rid of the "generate and sign a key that then sits on that computer that might not be fully trusted" step...
- zhfliz 4y agonot as flexible, as it has more dependencies, but you can make it work without gpg as well: https://developers.yubico.com/yubico-piv-tool/YKCS11/ https://developers.yubico.com/yubico-piv-tool/YKCS11/
- NjU24E48YqdBGnG 4y agoYes, I could. In fact I actually also use the PIV functionality, just not for SSH. The GPG answer seems simpler, at least for my use-case, since it really does just require SSH and GPG (okay, and GPG configured to `enable-ssh-support`). Also, I was actually using a GPG-as-SSH-key before I started hosting it on my Yubikey. Sadly, the Windows GPG build and Win32-OpenSSH don't talk to the agent the same way, so it doesn't work there. (AFAIR Windows GPG - and Putty - uses "Assuan" while Win32-OpenSSH uses named pipes just like *nix SSH/GPG do.) I don't think PIV would help that though :(
- dmuth 4y agoFor those curious about how SSH CAs and key signing works, I wrote a blog post about that awhile ago: https://dmuth.medium.com/ssh-at-scale-cas-and-principals-b27edca3a5d https://dmuth.medium.com/ssh-at-scale-cas-and-principals-b27... I also created a "playground" which can be used to stand up such an environment running in Docker containers to better understand the process: https://github.com/dmuth/ssh-principal-and-ca-playground https://github.com/dmuth/ssh-principal-and-ca-playground Hope folks here find them helpful.
- LionTamer 4y agoThat that looks rly helpful. I’ll check that out tonight, thanks for sharing
- rkangel 4y agoMy hope is to make this problem mostly redundant among my machines through use of tailscale. Tailscale SSH means that I don't have to worry about SSH keys at all - it just uses the same auth as the rest of tailscale. Only downside is that at the moment it doesn't play with SELinux which is a bit unhelpful for me given I mostly use Fedora.
- mdeeks 4y agoFor personal use cases this the the best option by far IMHO. At work we deployed Tailscale company wide but we almost entirely use subnet routers and don't have Tailscale on each node. So it only gets you as far as an SSH bastion. We instead rely on standard SSH keys to reach individual nodes and another third party service that dynamically provisions accounts and authorized_keys on machines when you try to login. I would kill for something as simple and clean as Tailscale SSH for all of our nodes at work. Especially since it has ACLs and optional "check mode" which forces re-auth/2FA for high risk nodes.
- rkeene2 4y agoI use X.509 certificates for SSH (via PKIXSSH [0])... but I'm not sure where that goes here [0] https://roumenpetrov.info/secsh/ https://roumenpetrov.info/secsh/
- zie 4y agoNo, because I needed to interoperate with Windows and at the time it didn't handle SSH CA certs. Maybe that's fixed now? Anyways, we use Hashicorp Vault's SSH OTP system. Works fine.
- vaporup 4y agoYes, I use them for work. Checkout ssh-certinfo also: https://github.com/vaporup/ssh-tools/blob/master/ssh-certinfo https://github.com/vaporup/ssh-tools/blob/master/ssh-certinf...
- robohoe 4y agoIAP wherever I can
- lapser 4y agoFor folks on AWS I highly recommend investing in SSH over SSM in combination with EC2 Instance Connect. You can generate temporary ssh keys, send it to EC2 Instance Connect, it'll be on the server for 60 seconds. Then you can use ssm start-session to connect to the server over SSM. This also allows you to disable SSH ingress, and doesn't need a bastion or VPN.
- darkr 4y agoIf you’re all in on AWS, this is the easiest and possibly best solution, solves a bunch of security, operational and usability problems if implemented in tandem with SSO, CloudTrail and well defined IAM roles.
- GNOMES 4y agoGoogle Auth on SSH is awesome too https://wiki.archlinux.org/title/Google_Authenticator https://wiki.archlinux.org/title/Google_Authenticator
- hedora 4y agoNote that using a CA cert with SSH (or putting a host cert in DNS, etc) expands the attack surface for your server from just that server to the server + the CA's servers + the CA's employees + potentially other CA's + whatever governments are able to compel the CA['s] to issue a MITM cert for your server. For big organizations security is by-definition lax (you have to trust lots of non-trustworthy employees), but there's no reason to accept this compromise for smaller companies or personal use.
- pphysch 4y agoThat's just the nature of trusting someone else to be your CA. You don't have to do that to use SSH certs.
- hedora 4y agoAt the minimum, you need to trust yourself to be a CA. That's strictly more attack surface than not having a CA.
- pphysch 4y agoIt's not "strictly" more because you reduce the attack surface of your leaf certs through expiration, etc.
- hedora 4y agoWhat attack does that prevent? If the leaf certs are compromised, then so is the server, and it is already game over.
- pphysch 4y agoIt prevents the attack where thousands of users have thousands of long-forgotten keys lying around, and eventually one of them gets compromised months or years after it was last legitimately used. AKA a huge attack surface that can't reliably be culled, because you are effectively relying on users to be their individual CAs. This particular attack took down my former organization once.
- pritambaral 4y agoI used to put CA keys, encrypted, in a repo only ops admins have access to. The passphrase was shared manually with each admin, once. If/when an admin left, the plan was to rotate the CAs. All SSH and TLS servers I used this for had the ability to use multiple CAs, so the rotation itself worked.
- yankaf 4y agopeople here are quite honest.
- onetimeusename 4y agoIt's possible to store the private CA keys on something like YubiKey hardware offline. That seems like a good trade off if you don't have access to a cloud based HSM. Ideally, the private CA keys would be stored in an HSM and used to sign any keys you needed with them. Note: this is not to be confused with using a FIDO/U2F hardware authenticators which is also a good idea. This can double not only has a PKI for hosts and users using SSH connections but you can also use the PKI for signature verification of arbitrary data.
- NjU24E48YqdBGnG 4y agoWe use SSH certificates for host keys at work. That way we can avoid the constant "is this the host key you were expecting?" that everyone just pounds 'y' through. I've used user certificates personally in the past but no more. These days my SSH key is a GPG key on my Yubikey. For (centralized) user auth at work we use Kerberos/GSSAPIAuthentication (Windows 10's ssh client finally has support for it! You don't have to go download a newer version off their Github!). Users are free to use that to drop an authorized_keys on systems themselves as desired.
- zikduruqe 4y agoI just use my GPG key for SSH authentication. One GPG ID is personal, one GPG ID is work... and the twain shall not cross.
- stavros 4y agoI have a FIDO2 key I use for SSH, can't beat the convenience nor the security: https://www.stavros.io/posts/u2f-fido2-with-ssh/ https://www.stavros.io/posts/u2f-fido2-with-ssh/
- 71a54xd 4y agoAnyone here done cool things with the YubiHSM? I've been dying to buy one for a year or so!
- exabrial 4y agoWe keep user keys in LDAP. LDAP is mainly read-only having many many replicas is pretty easy. This is by far the most elegant solution we've determined and allows for instant revoking of user accounts.
- _jal 4y agoWe use old-style public keys, but store them in LDAP. sshd has AuthorizedKeysCommand pointing to a script to retrieve for login. And we scan for things that look like keys.
- rav 4y agoTo SSH into servers at $work, I need to run a command to 2FA-authenticate against our SSO and obtain a short-lived SSH cert for my local SSH key. We have around 10 tech employees and around 40 servers and it's really nice when onboarding new servers or new employees that we don't have to juggle authorized_keys around, and when offboarding employees we no longer have stale authorized_keys files to worry about, since access will expire automatically after 20 hours once the employee is removed in SSO. There's no hardware backing the CA, and it's all homebrew (NIH style) 2FA-SSO with openssh CA invocations, but it works and is quite convenient. We also use the same CA for host keys (again, certs issued by our NIH-style homebrew fleet management), which allows us to avoid TOFU prompts when onboarding new servers.
- jleahy 4y agoAn option that's not in the list: check you CA key into source control (but with a very strong password). If you set the number of rounds large enough and have an excellent password this is sufficient (not as good as HSM, but probably safer than Vault). The real thing that gets me though, is how to deal with different users needing access to different subsets of machines. That's where I miss Kerberos.
- romx 4y agoI save CA root into private github repo for the pass app. Then i can sign certs whenever i need them.
- tehno 4y agoHas anyone here implemented Google's HIBA (https://github.com/google/hiba https://github.com/google/hiba) in addition to SSH CA/certs for the extra identity and grant checks? I'm thinking about implementing HIBA with Vault managed SSH certs, and would appreciate anyone's comments about this approach.
- fjni 4y agoAt work there's a command I run that then requires 2fa auth through our identity provider. As a result, my ssh key gets signed with both a time restriction and an ip restriction. Same mechanism for git interactions and server logins. I believe on the backend it's an HSM which does the signing.
- mutant 4y agoAll in on teleport here