This script connects to a SSH server to create a dynamic tunnel proxy. I'm assuming you use a private key for authenticating to the server.
To use this script you must first configure it according to your details. I have supplied some dummy values for the configuration fields to start with.
# SSH user
USER=johndoe
# Server domain/ip
SERVER=proxyserver.com
# Private key for authenticating to the server
KEY=~/.ssh/id_rsa
# SSH port of the server
SSH_PORT=22
# Local port to be used for proxy
PROXY_PORT=8999
# Start tunnel
./tunnel.sh start
# Stop tunnel
./tunnel.sh stop
# Restart tunnel
./tunnel.sh restart
# Tunnel status
./tunnel.sh status
Suppose you want to connect to server.com using the proxy service you've started using the script. Open your 'ssh_config' file (for Ubuntu),
sudo vim /etc/ssh/ssh_config
and enter the following at the end of the file. I'm using an example configuration. Please change the fields according to your own specifications.
Host server.ssh
Hostname example.com
Port 2020
IdentityFile ~/.ssh/server
User admin
ProxyCommand nc -x localhost:8999 %h %p
From now on you can ssh to the above server by using the following command,
ssh server.ssh
For using the proxy with firefox or other browsers just use the following configuration as Socks v5 proxy,
Server: 127.0.0.1
Port: 8999