How to Set Up a Custom Domain Name and TLS Certificate for Gophish on AWS
Setting up a custom domain name and a TLS certificate for Gophish on AWS can enhance the professionalism and security of your phishing simulations. Follow these steps to configure your Gophish instance with a custom domain and TLS certificate.
Step 1: Set Up a Custom Domain Name
- Access Your Gophish Instance:
Ensure your Gophish instance is running. You should be able to access it via the public IPv4 DNS on port 3636.
- Domain Name Configuration:
Purchase a domain name if you haven’t already. This guide uses Namecheap as an example, with the domain `hailbytes.store`.
- Create an A Record:
– Log in to your domain registrar (e.g., Namecheap).
– Navigate to the DNS settings and create a new A record.
– Set the host to `@` and the value to your Gophish instance’s IPv4 address.
– Save the changes and wait a few minutes for DNS propagation.
- Verify Custom Domain Access:
Open a browser and access Gophish using your custom domain with port 3636 (e.g., `http://hailbytes.store:3636`). You should see the Gophish login page.
Step 2: Set Up a TLS Certificate
- SSH into Gophish Server:
– Open your terminal and connect to your Gophish server via SSH.
– Use the connection string provided by AWS, making sure you have your SSH keys set up correctly.
ssh -i ~/path/to/your/private/key.pem ubuntu@your_server_ip
- Switch to Root User:
sudo su
- Remove Default Gophish Certificates:
– Navigate to the Gophish installation directory:
cd /opt/gophish
-Remove the default certificates:
sudo rm gophish_admin.crt
sudo rm gophish_admin.key
- Stop Gophish Service:
sudo systemctl stop gophish
- Install socat:
apt-get install -y socat
- Install Acme.sh:
Acme.sh is a tool to issue Let’s Encrypt certificates.
Wget -o – https://get.acme.sh | sh -s email=your-email@example.com
- Issue new certificate for domain mapping to instance ID
sudo /root/.acme.sh/acme.sh –issue -d hailbytes.store –standalone –server letsencrypt
If already issued then renew the existing certificate
sudo /root/.acme.sh/acme.sh renew hailbytes.store
Wait for at least 30 seconds to 1 minute before the next step
- Copy Certificates to Gophish Directory and Change Permissions:
sudo cp /root/.acme.sh/hailbytes.store_ecc/your_domain.com.key /opt/gophish_admin.key
sudo cp /root/.acme.sh/hailbytes.store_ecc/fullchain.cer /opt/gophish_admin.crt
chmod 0644 /opt/gophish/gophish_admin.crt
chmod 0644 /opt/gophish/gophish_admin.key
- Restart Gophish Service to apply new certificate:
sudo systemctl restart gophish
- Verify HTTPS Access:
Open your browser and access your Gophish instance via the custom domain (e.g., `https://hailbytes.store:3636`). You should see a secure connection with a valid TLS certificate.
By following these steps, you can set up a custom domain name and install a TLS certificate for your Gophish instance on AWS. This setup not only improves security but also adds a layer of professionalism to your phishing simulations. If you have any questions or run into issues, feel free to leave comments below or refer to the de