利用ssh的端口转发实现SOCKS5代理

SSH是一种安全的传输协议,用在连接服务器上比较多。不过其实除了这个功能,它的隧道转发功能更是吸引人。

ssh相关选项:

  • -V
    显示版本:
$ssh -V
OpenSSH_6.6.1p1 Ubuntu-2ubuntu2, OpenSSL 1.0.1f 6 Jan 2014
  • -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

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

这样就建立了SOCKS5代理。

使用SOCKS5代理

firefox浏览器:
打开firefox设置界面,如下设置:

缺点:

只能代理tcp数据,不能代理udp数据。

  • 0
    点赞
  • 20
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值