What are some of the best common sense, basic security practices in any Unix-like system? reddit / BSD ---------------------------------------------------------------------- cshurtsmybrain · 2019-05-15 09:35 Hello I'm just a curious learner. Any comments would be appreciated and I respect all opinions. Just wanted to pick the "collective brain" so to speak. Please post advanced subjects too, don't hold back. ​ \*Edit: I use FreeBSD 12-stable if that helps. ---------------------------------------------------------------------- moviuro · 2019-05-15 10:06 Use jails, learn about DNS, read https://vez.mrsk.me/freebsd- defaults.txt (with a bit of salt), etc. ---------------------------------------------------------------------- beowuff · 2019-05-15 10:23 Don’t run any services you don’t need. Don’t install unneeded software. Enable sshguard (or fail2ban). Audit your logs either on box or at a central logging server. Keep patches up to date. Monitor traffic to and from the box. ---------------------------------------------------------------------- h1ppie · 2019-05-15 11:36 Don't regularly log in as root. Create a separate user for day to day usage, elevate to root only when needed. ---------------------------------------------------------------------- masta · 2019-05-15 13:53 pre-reboot before applying any changes that would entail a reboot, to test for reboot survivability before any changes are applied. Sometimes an extant issue would cause problems, but the blame would be assigned to the current maintenance. This is substantially similar to regularly testing restore from backups, one cannot guarantee backups are working unless a restore from backup is regularly tested. Likewise one cannot assure reboots are working without actually rebooting regularly. Also, high uptime is retarded and a usually indicative of a poorly managed env. ---------------------------------------------------------------------- sparc64_ · 2019-05-15 14:10 > Don’t run any services you don’t need. > Audit your logs I feel like this is the most helpful answer for a beginner. If you start with the services running on your box, and in turn familiarize yourself with how the services interact, you will (most likely) begin to grasp how simple and straight forward security is a good chunk of time. ---------------------------------------------------------------------- beowuff · 2019-05-15 14:36 Yeah, I was just running down a quick mental list, but new users will learn a lot from those two! ---------------------------------------------------------------------- [deleted] · 2019-05-15 14:56 [deleted] ---------------------------------------------------------------------- _Evil_mind_ · 2019-05-15 17:23 On FreeBSD or NetBSD you can use blacklistd instead of sshguard or fail2ban. ---------------------------------------------------------------------- Calkhas · 2019-05-15 18:29 Don’t have sudo and don’t allow root log on over the network? Assume you have a headless machine, how do you get anything done? Straight to su? btw, I tried doas, but I never could get the environment variables right for comfortable use. (in particular the right LC_* language variables.) ---------------------------------------------------------------------- [deleted] · 2019-05-15 18:41 [deleted] ---------------------------------------------------------------------- GuinansEyebrows · 2019-05-15 21:39 and use sudo/doas instead of logging in as root whenever possible (since sudo commands are logged by default) ---------------------------------------------------------------------- hellbenthorse · 2019-05-15 23:05 Don't tell anyone your passwords. ---------------------------------------------------------------------- [deleted] · 2019-05-15 23:28 In a single user system, is logging in as root on tty2 acceptable? I'm aware that an attacker can use a browser exploit to take control of an open terminal window (where having a su # prompt could open the system up). But would they be able to access tty? I was under the understanding that the distrust is in the X server, but the console mode is more secure. ---------------------------------------------------------------------- Kernigh · 2019-05-16 05:19 If you log in as root, then the tty should belong to root, and users (other than root) should not be able open the tty. BSD uses the [revok e(2)](https://www.freebsd.org/cgi/man.cgi?query=revoke&sektion=2&aprop os=0&manpath=FreeBSD+12.0-RELEASE+and+Ports) system call to remove other users from the tty when someone logs in. Beware that root can give the opened tty to other users. For example, if I log in as root, then run `su kernigh`, then kernigh's shell would then access to root's tty. Other processes running as kernigh might be able to steal this access, perhaps using [ptrace(2)](https://www.freeb sd.org/cgi/man.cgi?query=ptrace&apropos=0&sektion=2&manpath=FreeBSD+12 .0-RELEASE+and+Ports&arch=default&format=html). A web browser in X11, running as kernigh, can access other windows (like terminal windows) in X, but it can also open and access all of kernigh's terminals inside or outside X. So if I log in as kernigh on a virtual console, or with ssh, then the browser can still access that tty. The browser might use TIOCSTI from [tty(4)](https://www.freebsd.o rg/cgi/man.cgi?query=tty&apropos=0&sektion=4&manpath=FreeBSD+12.0- RELEASE+and+Ports&arch=default&format=html) to type into the terminal, or might mess with the terminal in other ways. ---------------------------------------------------------------------- [deleted] · 2019-05-16 07:08 Wow thank you! I believed you, and I installed doas onto my FreeBSD machine then used doas pw lock root To lock root and disable su. doas has no persistence on non-OpenBSD machines. So if an attacker did show up, he'd have a harder time (sshd is disabled and I have no ports open at the time, disabled mail service, etc). I also changed my passwd storage from md5 to blowfish. I'm just a humble desktop user with a dayjob trying to pick up on good practices. CS is a hobby of mine. I use this as a password template [https://youtu.be/3NjQ9b3pgIg](https://youtu.be/3NjQ9b3pgIg) Edit: AFAIK FreeBSD 13-release with have...drum roll...ASLR turned off by default. But still available, whoo-hoo ikr...It's an easy config setting though, so I'm happy. I've already applied a lot of HardenedBSD's recommended sec defaults. ---------------------------------------------------------------------- techsnapp · 2019-05-19 05:09 Don't run as root. ---------------------------------------------------------------------- [deleted] · 2019-06-12 19:12 **Man pages are your friend.** Read them. Love them. Learn to write your own so that if you spot errors or notice that a man page is out of date you can help improve FreeBSD by submitting corrections. Also, since you're on FreeBSD, always keep [the handbook](https://www.freebsd.org/doc/handbook/book.html) handy. It's an excellent supplement to (and summary of) the man pages. Chapters 13-17 are particularly relevant to your questions about security.