Chris G wrote:
Normally the intruder would be coming from a different machine and wouldn't have the private key in the first place.
Not generally true unless they're doing IP spoofing as well because I only allow access from two specific IP addresses.
No...no..no..no
Connection from specific addresses is not to be considered a primary layer of security, it is a secondary one.
Your initial layers (from the something you have/are/know model) should be good enough that you would be happy enough using just one. Quite obviously an ipaddress isn't sufficient for that. So you need to build a secure layer of authentication first and then layer on top things like blocking from all but specific addresses as belt and braces.
Put it another way, I am guessing you are on a NAT'ed connection at home yes, so blocking access to an external machine from your external ip address doesn't just restrict access to your machine. Anything on your local network has this capability, as does anyone wanting to try at various points down the line, including your ISP or the ISP that is hosting the other machine.
You are making the same fatal assumption people do when they stick a firewall in front on an inherently insecure network and figure that makes them safe. The reality is you are better building a network that considers everything as equally untrusted until it has authenticated itself properly. That way if the firewall is breached or the attack comes from the private side of your network you are still going to give people a hard time....Good networks shouldn't *need* the firewall to be secure. By this stance you can treat blocking from all but specific IP addresses the same way, yes it helps but it is too easily spoofed so don't depend upon it.
The important case for me is access from 'out there' in to my machine (well, in to my server machine actually, there's a further hurdle to my desktop machine). The 'out there' machines are not mine, most definitely 'untrusted', the security rules then suggest that you *shouldn't* keep any private keys there.
No you don't do that, each machine 'out there' has it's own private key and put it's corresponding public key into authorized_hosts on your server. That way you can revoke access to an individual machine by deleting its key.
If you are talking about machines "out there" to which you have had no prior access to set up the keys then I would suggest that a. if you care about security you shouldn't be logging into your home system from them anyway and b. there are options to carry your (passphrase protected) private key on a memory stick and symlink it to ~/.ssh on the machine you want to access from. Or (personally I found that option annoying due to uid mapping issues) do what I do. I carry a qemu based VM (running DSL) that is bootable on Windows or Linux boxes from a memory stick which has it's own private key. It's passphrase protected anyway but if I lost the stick all I need to do is get it's public key out of my authorized_hosts.
However if we are following best practice here then private keys should never leave a machine, and you shouldn't be establishing a trusted connection from an untrusted host.
Don't make the mistake of dreaming up one possible attack vector and basing all your security measures upon that assumption. The fact is that if you are only allowing key based authentication then an intruder needs to break into your machine first *and* crack the passphrase on the private key. At the point your local machine is compromised and had you been using a password login to the remote system they could have just installed a keylogger or a login spoof and captured a password for the remote system anyway.
The key logger can capture my passphrase too can't it? Then the intruder has access to every system where I'm using that key.
Yes, but this is no worse than what a keylogger would do if it captured your passwords for interactive login. I was merely using this as an example of how key based auth doesn't *lower* security which is what you seem to be suggesting. At the point the passphrase (which can be more complicated if you like because you only need to remember one) is compromised you would have to assume that any and every password you have used on that machine would be equally so..no ?
So overall if you are using passphrase protected keys you have still increased overall security because the private key has to be stolen and compromised first. Making an attack from a machine other than yours pretty difficult and an attack from your machine as difficult as if they didn't have a password for interactive authentication (they still have to guess or capture the passphrase, which is the same effort as guessing or capturing a login password)
I can see what you're getting at and I half agree but I'm not sure that the game is worth the candle still.
Well the beauty is that it isn't really *that* much effort to set up and the benefits are well worth the effort in my opinion. Unless you only have a few passwords to remember or they are very simple/reused often you will generally have a hard time remembering them all. So ultimately you end up recording them all somewhere anyway :)