Hardening The Home Lab
Tags: linux, server, security, pentesting
Published: 2024-01-31 00:13:59

Peace,

Back at it with another post and today I wanted to speak about securing your home lab. Why have a home lab and there is no security yet daily practice security? After reading that question does it even make sense? Seriously with a bit of humor it really doesn't. That's why I wanted to take a moment to speak on the topic. Too many people I've came to meet in the field of cybersecurity have been showing me their labs. While able to browse the home lab, I notice that many aren't securing themselves leaving much vulnerability. I can only imagine someone practicing pen testing at home and find to be hacked themselves. No worries though, after reading this post it may help and bring perspective to why this should be done right away!

Like stated before, security of the home lab is important. This is what most would call "Hardening" your system because you are making it harder for actors to penetrate. You will hear the term "Hardening" sometimes so I wanted you to be familiar with it. There are several ways to execute hardening a system so don't feel as if this the only way. It's up to us all to continue to research so please be sure to read the resources listed below each blog post. 

**Hardening A System**

1. **Create a Hardening Checklist document**
When creating a checklist, be sure to include the following in the document.
 - Machine Name
 - IP address
 - MAC address
 - Name of person performing the system hardening
 - Date
 - Asset Number


2. **Use SSH:**
 - Each server should be configured to use SSH for remote login. 
 - IPTables are configured to restrict SSH access to known IP addresses only. 
 - Consider also disabling SSH on a not needed ports.
 - Key-based authentication should be used instead of password-based authentication
 - Client keys should be encrypted to prevent their use in case they are stolen
 - When configuring the server, root login should also be disabled and certain users have access when logged in.


3. **Close all Open Ports:**
  - Use netstat to find which devices are listening for incoming connections.
  - If you find an unnecessary service listening to inbound connections, disable the port or remove the application.

4. **Enable Firewall:**
  - iptables keep tab on incoming, outgoing, and forwarded practices can help you secure your server.
  - In the cloud, the VMs should be config to run in a ZERO Trust network.
  - Virtual Machine (VM) to VM communication is considered secured.


5. **Disable USB and Thunderbolt Devices:**
  - put a password protection on the BIOS so it can only be changed by authorized users.

6. **Turn On SELinux:**
  - Security-Enhanced Linux is built-in access control mechanism.
  - It operates in 3 modes:
	- Disabled: SELinux is completely off. Avoid this!
	- Permissive: doesn't enforce a policy, but logs and audits all actions.
        - Enforcing: most secure and enforces all polices. Default mode of SELinux and recommended.


7. **Strong Password Policy Implementation**
  - Disable accounts with empty passwords and ask users to set passwords for their accounts.
  - Encourage stronger passwords and harder to guess passwords by requiring guidelines.
  
8. **Purge unnecessary packages**
  - Eliminate all packages that you aren't using frequently.

9. **Keep kernel packages updated**
  - sudo apt-get update
  - sudo apt-get install upgrade

10. **Disable ICMP**
  - allows internet hosts to notify other hosts about errors and helps system admins in troubleshooting.
  - Attacks  that can happen when ICMP is enabled:
		- Ping Sweep:
		- Ping flood:

11. **Logging and Auditing**
  - Syslog logs all the messages in `/var/log dir` by default.
  - keeping detailed logging and audits can later be used to detect any attempted intrusions.

12. **Regular backups of the server.**
  - Use Rsync and other tools to back up the server consistently. 
  - Recommendations of cloud, offsite and onsite is provided but it's truly up to use case. 


Like stated prior, there are more options available for hardening your system. I wanted to give you a insight on things to focus on when starting the system hardening, but feel free to explore more. There are so many techniques and most apply to cloud systems / servers as well. 

Well, until next post.

Peace.


**Resources**

[Linux Server Hardening](https://www.cyberciti.biz/tips/linux-security.html)

[What is SSH?](https://www.ipxo.com/blog/what-is-ssh/)

[What is Netstat?](https://www.lifewire.com/netstat-command-2618098)

[What is SELinux?](https://www.redhat.com/en/topics/linux/what-is-selinux)

[What is ICMP?](https://www.cloudflare.com/learning/ddos/glossary/internet-control-message-protocol-icmp/)

[What is RSync?](https://jumpcloud.com/blog/how-to-backup-linux-system-rsync)