5 ms·
I think I need a list of things to check. This sounds pretty scriptable though: * SSH Host Key * SSH Authorized Keys * SSH PermitRootLogin * Disabling passw
by voltagex_ 13y ago
I think I need a list of things to check. This sounds pretty scriptable though:
* SSH Host Key
* SSH Authorized Keys
* SSH PermitRootLogin
* Disabling password auth in favour of keys
* Security updates from the distro
* SELinux (maybe?)
Anything else?
- icebraining 13y agoThe difference is that with most of those, you can create a snapshot of an instance and then duplicate the configuration, but Host keys are special, since they need to be re-created for each instance. In any case, there was discussion on those issues not long ago: https://news.ycombinator.com/item?id=5316093 https://news.ycombinator.com/item?id=5316093
- patio11 13y agoa) Move SSH off port 22. (Really limited security gain when implementing the rest of the suggestions, but saves spam in your logs.) b) Software firewall via e.g. IPtables is generally the first thing I turn on after rebooting SSHd with the new settings. c) (Optional) Consider using an architecture where you have N boxes and SSH only listens on a local interface on N-1 boxes, with the Nth box running nothing but your VPN. (This is also a good architecture choice for admin consoles, folks. www.example.com resolves to a public IP, admin.example.com resolves to a private IP, so even if they're technically speaking on the same box/boxes you won't lose the admin console if someone unwisely uses the same password for a WordPress blog somewhere.)
- dsl 13y agoMy honeypots have been seeing scans on 2022, 2222, 3022, etc. for years now. You should be setting proper ACLs for 22 and not moving to another port.
- RKearney 13y agoHostGator uses port 2222 for all their shared hosting. I never understood this, given how easy it would be to modify an attack to use the new port.
- voltagex_ 13y agoACLs as in allow/deny? What if I'm using a dynamic IP on my client? In that case, should I just be using a "trusted" SSH gateway?
- bigiain 13y agoConsider fail2ban. It can be configured to automatically add (and later remove) ip addresses to iptables based on login failures (found by running regexes on logfiles). I've got rules blocking ip addresses with multiple failed ssh or wordpress login attempts for an hour to be very effective. I've still got a bit of "brute force poop" in the logfiles, but much less than before. I've seen a suggestion for adding an additional fail2ban "recursive rule" - dropping any ip address with repeated fail2ban lockouts for much longer times - if you trigger multiple 1 hour lockouts for ssh auth failures, you might get dropped for a week or more. I haven't felt the need to implement that one yet.
- Domenic_S 13y agoThe name for c), assuming you harden the box a bit is a bastion host http://en.wikipedia.org/wiki/Bastion_host http://en.wikipedia.org/wiki/Bastion_host
- lmm 13y agoI've never understood the logic behind these software firewalls. If you have one enabled it's inspecting all incoming packets, exposing a large surface of what's often quite complicated C code. Any service that has bound to a public-facing port on a machine I run has done so because I wanted it to; if I had a firewall I'd need to add an exception for it. Any service that's only meant to be accessed from the same machine has bound on loopback. Services that are accessed from another "internal" machine are properly authenticated, which means the network doesn't have to be trusted; spoofing packets won't help an attacker at all. Frankly if your defences rely on the idea that all packets from ip xxx.xxx.xxx.xxx are "safe" you're going to get burned. Where's the value in a software firewall supposed to be?
- cdjk 13y agoWhat if you want to do something between "everyone can access it" and "only local host can access it?". For example, I have to run a recursive DNS resolver on a port other than 53 because my ISP intercepts DNS traffic. I've limited access to only my ISPs IPs at the software firewall, so as not to unwittingly take part in a DNS amplification attack. Or what if I want to run a mail relay but only allow machines I control to access it. Or block a user who's doing something nefarious? Sure, most services allow you to control access by ip, but I'd much rather manage it all in one place. And the ports show up as closed if you block at the firewall.
- lmm 13y ago>What if you want to do something between "everyone can access it" and "only local host can access it?". For example, I have to run a recursive DNS resolver on a port other than 53 because my ISP intercepts DNS traffic. I've limited access to only my ISPs IPs at the software firewall, so as not to unwittingly take part in a DNS amplification attack. Hmm. In that specific instance it makes sense, because spoofing the IP is the whole point of the attack. I'd argue that's basically unique to DNS though, in which case the advantage of managing it in the same place as your other services goes away. >Or what if I want to run a mail relay but only allow machines I control to access it. Then you use a real authentication mechanism (i.e. SMTP AUTH). Otherwise it would seem perfectly possible for a spammer to spoof one of your IPs and use your relay.
- gtani 13y agothese are pretty decen outlines http://www.quantisan.com/securing-a-fresh-ubuntu-server-with-fabric-tasks/ http://www.quantisan.com/securing-a-fresh-ubuntu-server-with... http://plusbryan.com/my-first-5-minutes-on-a-server-or-essential-security-for-linux-servers http://plusbryan.com/my-first-5-minutes-on-a-server-or-essen...
- deleted 13y ago[deleted]
- __david__ 13y ago> SSH PermitRootLogin I assume you mean to disable it? I see that listed in various places, but I don't understand why it matters… I like to kill all passwords on my VMs (so there's nothing to brute force), uninstall sudo and only use ssh keys to authenticate. I would like to know why this is a bad idea.
- jon-wood 13y agoThis is more of an issue on machines with multiple people who can access them. If you disallow logging in as root and use sudo to escalate privileges when needed then there's an audit trail of who did what (or at least a record of someone starting a shell with root privileges at around the time of something bad happening).
- VLM 13y agoA slight correction in that if you examine the logs on any SSH server connected to the net you'll see an absolute flood of Chinese (and other) compromised windows boxes trying to brute force (sorta) passwords for the root account using ssh. So if you disable root logins, they have no idea what to use as a username. Oh sure someone who personally knows which machine you maintain might be able to guess jonwood is your username or my username is vlm... but they'll never be able to log in as root and botnets aren't smart enough to try anything else. Aside from root, I wouldn't make your "primary user name" = "hostname" either. Thinking back at my occasional examination of logs, I don't know if I've ever been scanned by bot nets trying Anything other than root as a username. I'm sure it happens, but I can't afford to spend 5 minutes per syslog line in my life either...
- dbdr 13y agoI did see remote bots attempting to guess ssh usernames besides root. For instance bob, john, guest, ...