ssh利用端口轉發實現SOCKS5代理

jopen 10年前發布 | 67K 次閱讀 SOCKS5 網絡技術

現在linux下ssh使用比較廣泛的是openssh包

ssh相關選項:

  • -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>

  • -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)

    </li> </ul>

    建立SOCKS5代理:

    ssh -f -N -D bindaddress:port name@server

    • bindaddress: 指定綁定ip地址
    • port: 指定偵聽端口
    • name: ssh服務器登錄名
    • server: ssh服務器地址
    • </ul>

      例:
      ssh -f -N -D 127.0.0.1:1080 xiaoming@158.123.45.37
      這樣就建立SOCKS5代理。

      使用SOCKS5代理

      例:

      • chrome:
        chrome需要使用命令指定SOCKS5代理:
        google-chrome --proxy-server="socks://127.0.0.1:1080"

        </li>

      • firefox:
        在preferences=>advanced=> Network->connection->Settings里,勾選Manual proxy configuration,并將其它項清空,SOCKS Host設置為127.0.0.1,port設置為1080, 并勾選Remote DNS(勾選后可防止本地DNS污染),如圖。
        ssh利用端口轉發實現SOCKS5代理

        </li>

      • 其它,請搜索具體關于各自配置的文章:

        </li>

      • 使用代理插件switchysharp等

        </li>

      • 在系統自帶的代理設置全局代理

        </li>

      • 使用其它SOCKS客戶端實現代理,比如redsocks

        </li> </ul>

        參考

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!