This Bash script is designed to manage VPN connections using SSH and sshuttle. It supports both IPv4 and IPv6 connections and offers an optional graphical user interface (GUI) for ease of use.
- SSH Tunneling: Connects to VPN servers using SSH tunneling.
- sshuttle: Allows VPN connections with
sshuttlefor more advanced routing and DNS handling. - GUI Mode: Provides a graphical interface for selecting connection options.
- Command-Line Options: Offers flexible command-line options to control the script's behavior.
Before using the script, you'll need to configure it to match your VPN setup. Here's how:
-
Edit VPN Configuration:
Open the script in a text editor and modify the following variables to fit your VPN server details:
# VPN config user="" # SSH user for the VPN server ipv4="" # IPv4 address of the VPN server ipv6="" # IPv6 address of the VPN server port="" # Port used for the VPN connection local_port="" # Local port for SSH tunneling
user: The SSH username used to connect to the VPN server. Change it if your username is different.ipv4andipv6: The IP addresses of your VPN server for IPv4 and IPv6, respectively. Update these with your server's actual addresses.port: The port number on which the VPN server listens for connections. Ensure this matches your server's configuration.local_port: The local port used for SSH tunneling. Change this if you need a different port.
-
Install Required Tools:
Make sure you have the following tools installed on your system:
- SSH: The SSH client should be installed and configured.
- sshuttle: Install
sshuttleif you plan to usesshuttlemode. On Debian-based systems, you can install it withsudo apt-get install sshuttle. - Zenity: Install
zenityfor GUI mode. On Debian-based systems, you can install it withsudo apt-get install zenity.
./vpn_script.sh [-g] [-s] [-v ip_version]-g: Launch GUI mode.-v ip_version: Specify the VPN server IP version. Must be4for IPv4 or6for IPv6.-s: Usesshuttlemode (requires-v).
-
Connect via SSH with IPv4:
./vpn_script.sh -v 4
-
Connect via SSH with IPv6:
./vpn_script.sh -v 6
-
Connect via
sshuttlewith IPv4:./vpn_script.sh -v 4 -s
-
Connect via
sshuttlewith IPv6:./vpn_script.sh -v 6 -s
-
Launch GUI for VPN selection:
./vpn_script.sh -g
start_vpn(): Starts the VPN connection based on the IP version andsshuttlemode.launch_gui(): Launches a GUI for selecting the connection type.
- The script continuously attempts to reconnect if the connection is lost (for SSH connections).
- Ensure that
sshuttleis installed if you plan to use sshuttle mode. - Make sure
zenityis installed for GUI mode to work.
This script is released under the MIT License. See LICENSE for more details.
Feel free to adjust any details to better fit your specific setup or preferences.