Live data from Hacker News

Hardening SSH with 2FA

gist.github.com

21–30 of 103 posts

Re: Hardening SSH with 2FA

#21

I have two dozen co-located servers to log into. So far I've resisted the idea of setting up a bastion host, because that seems like a way to lock myself out of SSH access if that machine dies. I'm also not sure of the rationale for having a bastion host, other than "big companies do it". How do other non-cloud people handle this access vs. security tradeoff? I'm also curious what people's preferred fallback method i…

VPN

Re: Hardening SSH with 2FA

#22
post #11

I've thought about doing something like this several times, but the proposition of using any tools/libraries/pam modules/etc not installed by default, custom pam/sshd configs, and generally anything "outside of the box" sort of scares me. I've used 2FA for SSH at $lastjobatmegacorp, however all that infrastructure was supported by a team of people dedicated to such things. How finicky would setting this up for myself…

not a shill but I have great things to say about Yubikey. I'm a longtime linux enthusiast, but never a dojo master. Buying the yubikey and seeing the words "PAM module" made me expect a rodeo, but it was surprisingly easy. just from memory, but it was basically (on arch) 1) install the yubikey package, including a GUI utility to set up the Yubikey and PAM libraries (just .so files). 2) mess around with setting up the keys on the yubi. there are 2 slots that can be set up a variety of ways. 3) configure pam. it was basically one text file, and maybe copying a .so, way easier than I imagined. 4) set up ssh to only accept PAM authentication (delete 2-3 lines, add one line). 5) set up display manager to accept the yubikey OR password.

so this way, my always-on router can ONLY be accessed by a yubikey. That uses "slot 1", which requires me to insert the yubi and long-touch it(it only has one button). and my desktop can be accessed without a password if the yubi is inserted (without pressing it or anything, this is slot0) or I can type my password if I want.

what I thought was going to be a wild rodeo with bucking broncos and PAM module errors, turned out to be riding the coin-operated horse in front of the grocery store.

Re: Hardening SSH with 2FA

#23
post #14

This is a crutch, backwards approach. Just use smart cards goddammit, that's what they were made for! https://github.com/philipWendland/IsoApplet/wiki

Wait, really? They still make these? People still use them? How secure are they really compared to USB tokens like a Yubikey? How do you interface with one of these?

The DoD uses them extensively. All military personnel are issued one and it’s used for everything from accessing workstations and email to buying your meals at the DFAC.

Re: Hardening SSH with 2FA

#24
post #14

This is a crutch, backwards approach. Just use smart cards goddammit, that's what they were made for! https://github.com/philipWendland/IsoApplet/wiki

Wait, really? They still make these? People still use them? How secure are they really compared to USB tokens like a Yubikey? How do you interface with one of these?

> Wait, really? They still make these? People still use them?

Mandated by the US government so yes, lots of people use them.

https://en.wikipedia.org/wiki/Common_Access_Card

Re: Hardening SSH with 2FA

#25
If you're using a Vault system, it's also relatively easy and well documented to use Vault for this process. There's two components, which is the OTP configuration of Vault itself:

https://www.vaultproject.io/docs/secrets/ssh/one-time-ssh-pa...

You also have to configure the servers to support Vault, using their PAM integration:

https://github.com/hashicorp/vault-ssh-helper

Re: Hardening SSH with 2FA

#26
post #11

I've thought about doing something like this several times, but the proposition of using any tools/libraries/pam modules/etc not installed by default, custom pam/sshd configs, and generally anything "outside of the box" sort of scares me. I've used 2FA for SSH at $lastjobatmegacorp, however all that infrastructure was supported by a team of people dedicated to such things. How finicky would setting this up for myself…

I wrote a blog post on this recently, using only open-source tools that don't come from big corps. To have TOTP second factor on Debian (like) systems you need only libpam-oath module on the server, and perhaps an open-source app like FreeOTP (RedHat) on a smartphone.

I'm afraid to link it here because the traffic might kill my puny box.

Re: Hardening SSH with 2FA

#27
post #20
post #5

Earlier quoted context omitted.

> I'm also not sure of the rationale for having a bastion host It's a central place where you can do your logging, which many enterprises must do for compliance reasons.

Really? Do any compliance standards specifically require this? Or is the specific control defined in the organization itself that requires this? I've found many compliance standards to be pretty open-ended and function-driven, rather than prescribing specific standards. Client contracts.... they may be a different beast, and often require specific promises by vendors.

PCI-DSS comes to mind and it’s segmentation guideline, often met by deploying bastions.

Re: Hardening SSH with 2FA

#28
post #8

Earlier quoted context omitted.

I think the SOP is to have a second Yubikey registered and stored in a safe place and/or a set of one-time codes that you can use instead.

I actually had no idea SSH had support for one-time passwords, but I see docs for OTPW here: https://www.digitalocean.com/community/tutorials/install-and... This looks like exactly the answer I needed; thank you!

It sounds like you're trying to do something like Yubikey OTP or U2F with SSH. Both are doable, but I don't think that's the normal way people use hardware tokens with SSH; what I've seen much more is that people use Y4 keys (which are basically pocket HSMs), generate RSA keypairs with them, and configure SSH to accept the public key on the token.

This doesn't require any support on the serverside; as far as the server's concerned, the Y4 is just another RSA key.

It does require the more expensive Yubikey, but there are some security advantages to using it.

Re: Hardening SSH with 2FA

#29
post #11

I've thought about doing something like this several times, but the proposition of using any tools/libraries/pam modules/etc not installed by default, custom pam/sshd configs, and generally anything "outside of the box" sort of scares me. I've used 2FA for SSH at $lastjobatmegacorp, however all that infrastructure was supported by a team of people dedicated to such things. How finicky would setting this up for myself…

Megacorps have their own reasons to select technology. Your best bet is probably to go with a Yubikey (or something like it). It's about $50 and it's what several of the big Linux projects themselves use so it's well tested and documented.

Re: Hardening SSH with 2FA

#30
post #14

This is a crutch, backwards approach. Just use smart cards goddammit, that's what they were made for! https://github.com/philipWendland/IsoApplet/wiki

Wait, really? They still make these? People still use them? How secure are they really compared to USB tokens like a Yubikey? How do you interface with one of these?

Just about every Dell and Lenovo laptop from the enterprise lineup still comes with a SC reader option. In the enterprise world, smartcards are the de facto standard. I've heard complaints from $BIGCORP managers that they couldn't have iPads because they don't offer smartcard functionality.
Post reply on HN