Secure the Hell Out of Your Linux box
Since I’ve been writing this blog and collecting tutorials, I’ve tried to keep a focus on security and privacy. In light of your computer rights at boarder security, the House Passing the Pro-IP act, malicious script kiddies and crackers in this world, and if it’s a business machine, also worrying about your competition, there are a lot of people in this world that want to know what you’re doing on your computer and online, legally and illegally.
I’m not going to go through any actual tutorial here as most of everything I wish to explain I’ve covered, but tutorials will be linked. I just think step by step we should approach security in Linux.
Drive Encryption
First thing first we need to make sure our drives are encrypted. OpenSuse, Ubuntu, Debian, the upcoming Fedora 9 can all do this for you on the install.
- Use Yast to Encrypt Partitions
- Encrypted Root File System During Install in openSuse 10.3
- Encrypt Your Ubuntu During Install
- The option to encrypt the entire system is also present during the install for current offerings of Debian and Fedora (see Fedora screenshot below)

We will also want to secure access to the disks by placing a password on the BIOS (varies by system), by password protecting GRUB and single user mode.
Luks via Yast in openSuse, as well as TrueCrypt can also encrypt volumes within container files. I personally stay away from truecrypt for my linux discs and use it solely for my USB keys. Truecrypt cannot encrypt every volume on your linux system, and it’s better to use Luks.
File Encryption and Secure Deletion
You may want to further encrypt single files in case someone accesses your system while it’s up and running with your encrypted volumes mounted.
And furthermore hide files with steganography:
And when you no longer need files, securely delete them.
- Securely Delete Files with Wipe
- Securely Delete files from Journaling Filesystems in Linux
- Delete Files Permanently and Securely with Shred & SecureDelete
Securing Your System from Network Based Attacks
First thing you should try to abide by as close as you possibly can are the NSA Guides to Securing Redhat Enterprise Linux. This can be applied to just about any distribution. This is a must read.
You will also want to learn a bit about AppArmor or SELinux, depending on your distro.
It’s also a good idea to do file transfers to other machines with ssh/scp or sftp, rather than unencrypted protocols:
- Basics of ssh and scp
- The basics of ftp and sftp(remember, it’s generally better to simply use sftp on a machine that’s already running the ssh server so you’re not running more services than necessary. The less there is running, the less there is to make mistakes with and the less vulnerabilities that are exposed.)
You need to know how the linux firewall works (iptables) and configure it tightly. Only allow incoming and outgoing services that YOU manually chose.
It is also best to run a firewall on your system on top of a firewall provided by your router. On the router, keep the firmware upgraded. Do not allow remote administration of the device, be sure to change it’s default password. Only use wireless if you absolutely need to. If you must turn it on, use WPA over WEP. WPA is much harder to crack.
If you must have the SSH Server turned on, really lock down your box concerning this service:
- Linux to Linux Key Based SSH
- Preventing Brute Force Attacks With Fail2ban(somewhat OpenSuse centric)
- Protect SSH Access With hosts files and a proper sshd_config(tcp wrappers)
- Mounting a SSH folder locally with sshfs
- My Personal Tip: Get a piece of junk computer or put one together. Follow the tutorials above regarding using SSH keys, fail2ban (denyhosts is another alternative), properly configure the tcpwrappers, configure the sshd_config properly, limit what users can ssh out of the machine in the ssh_config, configure the firewall tightly, but do not store any data on this machine. Now this machine should be the only machine allowed to connect to your pc within your network. On your machine, duplicate all the following tutorials.
So the connection inwards should look like this: Your ssh connection –> Forward through non-standard port on the router –> to the junk machine after being allowed through via RSA Key/firewall/tcpwrapper/fail2ban/sshd_config –> to your machine after being allowed through RSA Key/firewall/tcpwrapper/fail2ban/sshd_config again.
Overkill? More than likely.
Know who is on your system and know file permissions
First thing you want to know is file and directory permissions. If a user does not have the proper permissions to a file this can be a lifesaver preventing the wrong information from getting into the wrong hands.
You can also check who’s currently logged onto your system with the ‘w’ or the ‘who’ command. And if you don’t like what you see….
Using Linux as a Secure Desktop
But what about everything else? All those applications we need day to day, email, web surfing, chatting with some buddies, all of this is open to be sniffed by someone else and various vulnerabilities can compromise your system.
Browsers: Most of us already use Firefox. And there’s some ways to make Firefox more secure.
- NoScript
- CookieSafe
- SafeCache
- Use https sites when the option is available.
- Set Firefox to clear private data each time the browser is closed as well.
- In regards to a master password, I avoid Firefox or any browser saving any password. There’s a debate as to whether the MasterPassword to protect your saved passwords is really more secure.
Chat: Use Pidgin with Off the Record Messaging or Gaim Encryption. Encourage others to use Pidgin with OTR or Gaim Encryption as well.
Email: I’ve found Evolution and Thunderbird the easiest to setup GPG encryption on. I love me some Kmail, but until security integration works better, I’ll stick with one of these two:
Bit Torrent: There’s very few networks that are monitored as heavily as bit torrent. But I just can’t keep myself from it. There’s a number of approaches I take.
To avoid traffic shaping, encrypt the bit torrent headers.
Use a client that supports PeerGuardian Blocklists.
- Ktorrent (built in, but must be enabled)
- Deluge (built in, but must be enabled)
- Azureus with SafePeer
Use a secure VPN service when using Bit Torrent:
Check Regularly for Compromises
Check for Rootkits: Rootkits are probably the thing you need to check for most. As most Unix based systems normally don’t get infected with spyware and viruses.
Check for Viruses: But just in case there is a virus, you should know how to scan for them and remove them.
Port Scan Attacks: Also you should know how to periodically scan for port scan attacks.
There are a number of systems to aid you in finding compromises and break-ins as well.
And of course there’s some common sense tips:
- Use strong 12+ character, alphanumeric, upper and lower case passwords, with a symbol that change frequently. Try to avoid words and names as they are vulnerable to dictionary based attacks.
- When you have the chance to use encrypted keys in place of or in addition to passwords, do so.
- Change your password every 45-90 days.
- Never leave your machine logged in when you are away from the box.
- If possible, keep the system turned off when you’re not using it. If single user mode, grub, the bios, and the unlocking ability for your encrypted drives are all password protected it would be hell to get into the box itself from an off state. Also, in the extremely rare cases that someone can freeze your ram to obtain your LUKs keys, if your machine is already in an off state, chances are those keys will not be in your memory by the time someone accesses the box.
- Do not allow passwords to be saved by any application. This is tricky with security. Sometimes saved passwords can avoid keyloggers, but if a password is stored, it generally can be retrieved (like Pidgin’s/Gaim’s plaintext accounts.xml file).
- Extremely limit the personal data you store online. Run your own email server if you have the ability to and learn how to secure that. If you use a third party web mail service, use something along the lines of Hushmail.
- Do your updates regularly for your system and make sure any repository you connect to is one you can trust.
- When confronted with law enforcement, know your rights in the country you reside in. For American’s: it’s good to acknowledge that the courts have found passwords that protect encrypted information is protected by our 5th Amendment. You do not have to provide them to anyone.
- Do not stay logged into the root account. If you log into it in anyway, via ssh, on the commandline locally, or into the desktop environment, and have a problem remembering that you logged in, start using sudo instead.
- Don’t get cocky or arrogant with how secure your system is. This is extremely important. Many mac guys and even unix guys criticize how insecure Windows is, and Microsoft products in general. But the main weakness in Windows is it’s users. And that doesn’t change just because you’re using a system with a low adoption ratio, and that doesn’t change simply because you have a unix box. You are not invincible. The safest computer is a non-existing one and there is no such thing as being 100% secure. If you can remember that and not be elitist and arrogant about it like a certain fruit loving tech crowd, you’re good to go.











on May 9th, 2008 at 3:02 pm
[…] Peter L. Whittle […]
on May 9th, 2008 at 3:35 pm
Story added…
This story has been submitted to fsdaily.com! If you think this story should be read by the free software community, come vote it up and discuss it here:
http://www.fsdaily.com/EndUser/Secure_the_Hell_Out_of_Your_Linux_Desktop_Server...
on May 10th, 2008 at 7:07 am
Sudo is great for preventing mistakes, logging and giving limited access for certain users. However, is using sudo really good advice when it is configured to give permission to run any command as root? If there is a bug e.g. in your in web browser or pdf viewer the attacker can run “sudojump” with as your normal user. Next time you use sudo it will silently change the arguments of sudo so it’ll execute something entirely different:
http://www.quantumg.net/sudojump.php
on May 12th, 2008 at 12:41 pm
[…] Read more at Tux Training […]