How to Set Up a Custom Domain Name and TLS Certificate for Gophish on AWS

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

  1. 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.

  1. Domain Name Configuration:

   Purchase a domain name if you haven’t already. This guide uses Namecheap as an example, with the domain `hailbytes.store`.

  1. 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.

  1. 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

  1. 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

  1. Switch to Root User:

   sudo su

  1. 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

  1. Stop Gophish Service:

   sudo systemctl stop gophish

  1. Install socat:

  apt-get install -y socat

 

  1. 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

  1. 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

  1. 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

  1. Restart Gophish Service to apply new certificate:

   sudo systemctl restart gophish

  1. 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