Simple Shell Script to Manage SSH Tunnels

Manage SSH Tunnel is a simple shell script to start and stop ssh tunnels from the terminal.

Setup

Note: the setup assumes bash as the default shell

  1. Download tunnel.sh and save it to ~/bin/
  2. Add to ~/.bash_profile or ~/.bashrc

    alias tunnel_home='/bin/sh ~/bin/tunnel.sh example.net sam 22 8888'
    
  3. Replace example.net with the hostname of the server, sam with the username on the server, and 8888 with the local tunnel port

  4. Type source ~/.bash_profile or source ~/.bashrc

Usage

  1. To open the tunnel

    tunnel_home start
    
  2. To close the tunnel

    tunnel_home close