
How to Install Gophish on Ubuntu 22.04: A Step-by-Step Guide
In today’s cybersecurity landscape, strengthening your organization’s human firewall is more critical than ever. Phishing attacks remain one of the most common vectors for security breaches, making employee training an essential defense. Gophish is a powerful, open-source phishing framework that allows you to run realistic phishing simulations to test and train your team, identify vulnerabilities, and improve overall security awareness.
This guide will provide a comprehensive, step-by-step walkthrough for installing and configuring Gophish on an Ubuntu 22.04 server.
Prerequisites
Before we begin, ensure you have the following:
- An Ubuntu 22.04 server (a fresh installation is recommended).
- Access to a user account with
sudo
or root privileges. - The
unzip
utility installed. If not, you can install it withsudo apt install unzip
.
Step 1: Update Your System
First things first, let’s make sure your system packages are up to date. This is a crucial first step for both security and stability. Open your terminal and run the following commands:
sudo apt update
sudo apt upgrade -y
Step 2: Download the Gophish Framework
Gophish is distributed as a pre-compiled binary, which simplifies the installation process. We will download the latest release directly from its official repository.
- Navigate to the Gophish releases page on GitHub to find the latest version.
- Locate the file for 64-bit Linux, which will typically be named
gophish-vX.X.X-linux-64bit.zip
. - Copy the link address for this file.
Now, use the wget
command in your terminal to download the archive. Replace the URL below with the one you just copied.
wget https://github.com/gophish/gophish/releases/download/v0.12.1/gophish-v0.12.1-linux-64bit.zip
Step 3: Unpack and Organize Gophish
Once the download is complete, you’ll have a ZIP file in your current directory. Let’s create a dedicated directory for Gophish to keep our system organized and then unzip the archive into it.
# Create a directory for Gophish in /opt (a standard location for optional software)
sudo mkdir /opt/gophish
# Unzip the archive into the new directory
sudo unzip gophish-v*.zip -d /opt/gophish
Step 4: Configure the Gophish config.json
File
This is the most important configuration step. Gophish is controlled by a single configuration file named config.json
. We need to edit this file to make the admin interface accessible from your IP address.
By default, the admin server only listens on 127.0.0.1
(localhost), meaning you can’t access it remotely. We will change this to 0.0.0.0
to allow connections from any network interface.
Open the configuration file with a text editor like nano
:
sudo nano /opt/gophish/config.json
Find the admin_server
section and change the listen_url
from 127.0.0.1:3333
to 0.0.0.0:3333
.
{
"admin_server": {
"listen_url": "0.0.0.0:3333",
"use_tls": true,
"cert_path": "gophish_admin.crt",
"key_path": "gophish_admin.key"
},
"phish_server": {
"listen_url": "0.0.0.0:80",
"use_tls": false,
"cert_path": "example.crt",
"key_path": "example.key"
},
"db_name": "gophish.db",
"db_path": "gophish.db",
"migrations_prefix": "db/db_",
"contact_address": "",
"logging": {
"filename": "",
"level": ""
}
}
Security Tip: Exposing the admin interface to the public internet is risky. For production environments, it is highly recommended to keep the listen_url
as 127.0.0.1:3333
and access it via an SSH tunnel or configure a firewall to only allow access from your specific IP address.
Save the file and exit the editor (in nano
, press Ctrl+X
, then Y
, then Enter
).
Step 5: Configure the Firewall
To access Gophish, we need to allow traffic through the server’s firewall. We will use ufw
(Uncomplicated Firewall) to open the necessary ports.
- Port 3333: The Gophish admin interface.
- Port 80: The phishing server that serves the landing pages.
# Allow the admin port (restrict this to your IP if possible for better security)
sudo ufw allow 3333/tcp
# Allow the phishing simulation port
sudo ufw allow 80/tcp
# Ensure SSH is allowed so you don't lock yourself out
sudo ufw allow ssh
# Enable the firewall
sudo ufw enable
Step 6: Run Gophish for the First Time
We are now ready to launch Gophish. Navigate to the directory and execute the binary.
cd /opt/gophish
sudo ./gophish
When you run it for the first time, Gophish will generate a one-time administrative password and print it to the console. Look for a line that says Please login with the username admin and the password ...
.
Copy this password immediately, as you will only see it this one time.
Now, open a web browser and navigate to your server’s IP address on port 3333: https://<your_server_ip>:3333
.
You will see a browser warning because Gophish uses a self-signed SSL certificate by default. This is expected. Proceed past the warning.
Log in with:
- Username:
admin
- Password: The temporary password you copied from the terminal.
You will be prompted to change your password immediately upon login. Choose a strong, unique password and store it securely.
Making Gophish Production-Ready: Run as a Service
Running Gophish directly in the terminal is fine for testing, but it will stop as soon as you close your session. For a permanent setup, we should run it as a systemd
service.
Create a service file for Gophish:
sudo nano /etc/systemd/system/gophish.service
Paste the following configuration into the file. This tells the system how to manage the Gophish process.
[Unit] Description=Gophish Phishing Framework After=network.target [Service] User=root WorkingDirectory=/opt/gophish ExecStart=/opt/gophish/gophish Restart=always RestartSec=3 [Install] WantedBy=multi-user.target
Save and close the file.
Now, reload the
systemd
daemon, enable the Gophish service to start on boot, and start it immediately.# Reload systemd to recognize the new service sudo systemctl daemon-reload # Enable the service to start automatically on boot sudo systemctl enable gophish # Start the service now sudo systemctl start gophish
You can check the status of the service at any time with sudo systemctl status gophish
. Your Gophish instance is now running persistently in the background.
Congratulations! You have successfully installed, configured, and deployed the Gophish phishing framework on your Ubuntu 22.04 server. You are now ready to create your first campaigns, design email templates, and begin strengthening your organization’s security posture.
Source: https://kifarunix.com/install-gophish-on-ubuntu-22-04/