博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

建立SOCKS5代理

Posted on 2018-03-22 22:56  wangyanlb  阅读(1105)  评论(0)    收藏  举报

ssh相关选项:

  • -V 
    显示版本: 
$ssh -V
OpenSSH_6.6.1p1 Ubuntu-2ubuntu2, OpenSSL 1.0.1f 6 Jan 2014
  • 1
  • 2
  • -f 
    输入密码后进入后台模式 
    (Requests ssh to go to background just before command execution.)

  • -N 
    不执行远程命令,用于端口转发 
    ( Do not execute a remote command. This is useful for just for warding ports (protocol version 2 only).)

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

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

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

bindaddress :指定绑定ip地址 
port : 指定侦听端口 
name: ssh服务器登录名 
server: ssh服务器地址

例如,假设把一个树莓派作为SOCKS5代理服务器,该树莓派的IP地址是192.168.4.160,SOCKS5的端口7070,在树莓派中输入如下命令:

ssh -f -N -D 192.168.4.160:7070 pi@127.0.0.1
  • 1

这样就建立了SOCKS5代理。