SSH - Two-factor or Key pairs?

May 19, 2014 3.7k views
Anyone who has an opinion on which method is the best to protect SSH, keypairs or the two factor authentication below? To protecting houses we first had private keys and public keyholes. Then door codes. Then access cards combined with a code. I mean when I lose my key I also lose access to my server and someone else might get access instead. Even if I protect my private key with a password it's easy to hack on someone's computer if it gets lost. If I store a password on a server It's not so easy to hack it if I have fail2ban and port knocking. Keys always need to be stored somewhere, unencrypted discs, smartphones, dropbox etc. An easy-to-remember 18+ character password only need to be stored in a non-hackable brain. And combined with two factor authentication it seems to me safer then using key pairs. If I use the Google Authenticator app in my phone I can still lose my phone/sim card. But if I also enable two-factor for a second phone I can always store that sim card in a safe place to always have access to my server, just in case I lose my phone. And if anyone get access to my phone they still need to know the ssh password. Anyone who has an opinion on this?
3 Answers
2FA Works Great, make sure you backup your private keys in a safe place though incase you loose or break your phone.

2factor is great because your phone can be offline and only you can access it if you have that phone or super long pin.

What I dont like about keys is that they have to be stored on a computer and are hard to backup if you loose them.

Johnathan Martin
We have both, normally we use keys and in case that it's an emergency or the like, we can log in with 2FA.

Additionally we have fail2ban and synchronize our block list over all our servers with

@sim thanks for the info on Hopefully this'll reduce the number of fail2ban emails I get on a daily basis.
Have another answer? Share your knowledge.