3 ms·
I'm not the best person at this, but I do the following on any machine I deal with which does not sit behind a firewall: 1. Disable root logins via ssh (as not
by gcv 19y ago
I'm not the best person at this, but I do the following on any machine I deal with which does not sit behind a firewall:
1. Disable root logins via ssh (as noted above by bbb).
2. Move ssh port from port 22 to something nonstandard. According to my logs, the number of idiots who try brute-force attacks on my machines dropped from 4/day to 0.
3. Put an iptables script into /etc/init.d and make sure it runs on startup at the normal multiuser run levels (on Debian, the command is something like /sbin/update-rc.d, but I don't remember exactly). I looked into more sophisticated firewall packages which generate iptables rules, but found them rather complicated, and probably overkill (YMMV). I essentially blocked all incoming traffic except on the nonstandard ssh port and ports 80 and 443.
Services which use ports other than 80, 443, and ssh should run on a privately routed network, or, at minimum, on a separate network interface with draconian access rules. iptables is pretty easy to use once for this stuff you get the hang of it.
- edu 19y agoThis is great advice. I will simply add one more thing (and two bonuses): 4. Disable password authentication for SSH and use a public/private key. Of course, use a good password on the private key. 5. (bonus) keep the installed software to the bare minimum. Less software, less bugs. 6. (extra bonus) look apache's mod_security, it's an application level firewall (filters requests to the application, so, for example, you can filter SQL injections or invalid characters before they reach your app).