ssh利用端口轉發實現SOCKS5代理
現在linux下ssh使用比較廣泛的是openssh包
ssh相關選項:
-
</li>-V
顯示版本:
ssh -V
OpenSSH_6.6.1p1 Ubuntu-2ubuntu2, OpenSSL 1.0.1f 6 Jan 2014
-
</li>-f
輸入密碼后進入后臺模式(Requests ssh to go to background just before command execution.) -
</li>-N
不執行遠程命令,用于端口轉發( Do not execute a remote command. This is useful for just for warding ports (protocol version 2 only).) -
</li>-D
socket5代理(Specifies a local “dynamic” application-level port forwarding.Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh will act as a SOCKS server.) -
</li>-L
tcp轉發(Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.) -
</li> </ul>-C
使用數據壓縮,網速快時會影響速度(Compression is desirable on modem lines and other slow connections, but will only slow down things on fast networks.The compression algorithm is the same used by gzip)建立SOCKS5代理:
ssh -f -N -D bindaddress:port name@server
- bindaddress: 指定綁定ip地址
- port: 指定偵聽端口
- name: ssh服務器登錄名
- server: ssh服務器地址 </ul>
-
chrome:
</li>
chrome需要使用命令指定SOCKS5代理:
google-chrome --proxy-server="socks://127.0.0.1:1080"
-
firefox:
</li>
在preferences=>advanced=> Network->connection->Settings里,勾選Manual proxy configuration,并將其它項清空,SOCKS Host設置為127.0.0.1,port設置為1080, 并勾選Remote DNS(勾選后可防止本地DNS污染),如圖。
-
其它,請搜索具體關于各自配置的文章:
</li> -
使用代理插件switchysharp等
</li> -
在系統自帶的代理設置全局代理
</li> -
使用其它SOCKS客戶端實現代理,比如redsocks
</li> </ul>參考
- SSH隧道與端口轉發及內網穿透
- OpenSSH官網 </ul> </div> 來自:http://my.oschina.net/u/1382972/blog/342092
例:
ssh -f -N -D 127.0.0.1:1080 xiaoming@158.123.45.37
這樣就建立SOCKS5代理。使用SOCKS5代理
例: