# Securing the Build Server

## Build Server Basics

&#x20;The simplest point to start is with access. Even in modern times, a common attack against build infrastructure is to guess credentials and gain access. Whenever you see a Jenkins server out in the wild, you would be surprised how many times `jenkins:jenkins` would do the trick!

To secure our build server, we want to restrict access to it. You would often find that multiple members have access to the same build server. In these cases, we need to apply granular access to ensure that a compromise of one user would not lead to the compromise of all builds. Furthermore, we want to restrict the likelihood of a user being compromised by using multifactor authentication.

## Protecting the Build Server

The following steps can be followed to protect both your build server and build agents:

1. **Build Agent Configuration**: Configure build agents to only communicate with the build server, avoiding external exposure.
2. **Private Network**: Place build agents within a private network, preventing direct internet access.
3. **Firewalls**: Employ firewalls to restrict incoming connections to necessary Build server-related traffic.
4. **VPN**: Use a VPN to access the build server and its agents securely from remote locations.
5. **Token-Based Authentication**: Utilize build agent tokens for authentication, adding an extra layer of security.
6. **SSH Keys**: For SSH-based build agents, use secure SSH keys for authentication.
7. **Continuous Monitoring**: Regularly monitor build agent activities and logs for unusual behavior.
8. **Regular Updates**: Update both the build server and agents with security patches.
9. **Security Audits**: Conduct periodic security audits to identify and address vulnerabilities.
10. **Remove Defaults and Harden Configuration**: Make sure to harden your build server and remove all default credentials and weak configurations.
