I. Script Functions
SSH dynamic forwarding from remote to local port
Ii. script configuration
Username user
Hostname: the IP address or domain name of your host
Port can be customized. The default port script is 9000.
Iii. Script
Proxy. Sh
#! /Bin/bash # author firxiao # ssh port forwarding hostname = XXXX # host name or ipusername = XXXX # username Port = 9000 # local listening port pid = 'ps ax | grep-I [email protected] $ hostname | grep-V grep | awk '{print $1} ''function start () {if [-n "$ PID"]; then {echo "the proxy ($ {pid}) alreay running... "Exit 1} else {nohup/usr/bin/ssh-d $ port $ hostname-N> log.txt 2> & 1 & Echo" the proxy started... OK "} fi} function stop () {if [-z" $ PID "]; then Echo" No proxy running. "Exit-1; FI echo" the proxy ($ {pid}) is running... "Kill $ {pid} echo" Send shutdown request to proxy ($ {pid}) OK "} function status () {if [-z" $ PID "]; then ECHO "No proxy running. "Exit-1; FI echo" the proxy ($ {pid}) is running... "} case $1 instart) Start; stop) Stop; Status) status; *) echo" useage: $0 START | stop | status "esac
3. Configure switchysharp
Select socks V5 Protocol
Proxy address 127.0.0.1 9000
SSH port forwarding reference http://www.ibm.com/developerworks/cn/linux/l-cn-sshforward/index.html
SSH port forwarding script