News for hackers. Stuff that matters.
Re:Ask HN: What are the best practises for using SSH keys? by zimbatm on Sunday September 25, 2016 @07:45AM (#12574918)
If you use fail2ban make sure to pin the right key to the right host. Otherwise ssh will try all the keys and get you banned from your own host. The easiest way is to use the ~/.ssh/config:

    Host myhost
      IdentityFile ~/.ssh/myhost
Re:Ask HN: What are the best practises for using SSH keys? by chmike on Sunday September 25, 2016 @08:21AM (#12575008)
Good advise. This happenned to me. By luck I had another account I could use to recover. I wish I could disable that feature. I use config now but the default should not be to try every key in ssh directory.
Re:Ask HN: What are the best practises for using SSH keys? by kardos on Sunday September 25, 2016 @09:12AM (#12575158)
Agreed. That seems like a weakness in OpenSSH. One should have to turn on a "try all keys" option to get that behaviour ..
Re:Ask HN: What are the best practises for using SSH keys? by jlgaddis on Sunday September 25, 2016 @04:01PM (#12577113)
Yeah, it's on by default. See IdentitiesOnly to turn it off.
Re:Ask HN: What are the best practises for using SSH keys? by sseagull on Sunday September 25, 2016 @10:39AM (#12575515)
It still may try other identity files. You need the IdentitiesOnly option, I believe.

I've been bitten by this a few times.

Re:Ask HN: What are the best practises for using SSH keys? by Tharkun on Sunday September 25, 2016 @09:33AM (#12575238)
You should do this even if you're not using fail2ban. Otherwise any box you connect to can enumerate all of your public keys, which could be a problem for some people.
Re:Ask HN: What are the best practises for using SSH keys? by zwily on Sunday September 25, 2016 @10:50AM (#12575569)
I don't think doing this actually prevents that. Your full agent is still forwarded. You need to use a separate agent per key if you want to prevent the remote host from using your other keys.
Re:Ask HN: What are the best practises for using SSH keys? by sneak on Sunday September 25, 2016 @09:17AM (#12575181)
If you're using key based auth exclusively, you don't need fail2ban.
Re:Ask HN: What are the best practises for using SSH keys? by fail2fail2ban on Sunday September 25, 2016 @11:41AM (#12575771)
fail2ban is for any log you want to monitor and block access to your machine for; not just ssh. fail2ban isn't a "keep my logs clean" tool it's a "reduce my attack surface" tool.

Edit: Feel free to Google "fail2ban security" if you disagree.

Re:Ask HN: What are the best practises for using SSH keys? by loeg on Sunday September 25, 2016 @09:21AM (#12575190)
Also, low values of the sshd option "MaxAuthTries" makes having multiple keys annoying. There are servers I have to log into with "1" or "2". It's really annoying and doesn't enhance security, especially with "PasswordAuthentication no".