在终端下间接使用Socks5代理的几种方法(privoxy,tsocks,proxychains)

Use socks5 proxy for pip install Issue pip install doesn’t provide the native socks5 proxy support. Solution Use a tool named proxychains which chains the connection through proxy. On Fedora, install via sudo dnf install proxy chains. To change the default socks5 proxy, modify /etc/proxychains.conf, under [ProxyList] add one line: socks5 127.0.0.1 1080 How to use: proxychains pip install requests Done! Happy pip with socks5 proxy.     不知道为什么今天PPA又只能使用代理访问了。好像终端不支持Socks5代理 没办法。咱转换吧。 (以下方法合用几乎可以使linux下面大多数软件实现代理通信,即使软件本身不支持)

1.使用tsocks转接

简单介绍下配置方法

我们可以这样测试一下

效果那是立竿见影啊!遗憾的是似乎已经停止开发了,而且ssh和ftp不工作,其官方网站你推荐了另外一个替代品,Dante,这个配置有点复杂,后面我会给出一个更好的替代品。

2.使用privoxy转换Socks5->HTTP代理

在最后一行加入

注意后面有个点 1080是本机的Socks代理端口 然后用service把privoxy给restart一下即可 默认监听的端口是本机的8118 如果要监听所有端口或者更换所有端口 把

改为

即可 这个虽然有点杀鸡用牛刀的意思,而且privoxy的鉴权不好实现。但是还是个好方法。

3.使用proxychains完美替代

配置非常简单,软件有3种代理模式

# Dynamic – Each connection will be done via chained proxies # all proxies chained in the order as they appear in the list # at least one proxy must be online to play in chain # (dead proxies are skipped) # otherwise EINTR is returned to the app 动态模式 按照列表内指定的代理的顺序执行代理操作,遇到不可用代理时会自动切换 至少需要一个可用代理 # Strict – Each connection will be done via chained proxies # all proxies chained in the order as they appear in the list # all proxies must be online to play in chain # otherwise EINTR is returned to the app 严格模式 代理顺序严格按照列表顺序来,列表内代理必须全部处于可用状态 # Random – Each connection will be done via random proxy # (or proxy chain, see chain_len) from the list # this option is good for scans 随机模式 随机选择代理代理列表里面的代理,代理个数由chain_len决定(如果你的代理个数少于chain_len个数,会报错)

[ProxyList]配置节指定了代理列表。支持socks4/5 http等 还支持带认证的代理 比如

type host port [user pass] socks5 192.168.67.78 1080 lamer secret

贴一下我的配置文件

使用方法和tsocks是一样的,比如


遗憾的是,以上几款都不支持基于用户名和密码的鉴权! 本机用用可以,想要小圈子内共享是个大问题!


更加专业工具

如果你有一VPN线路出国,想要和朋友共享这条加密隧道,但是又不方便把VPN共享,或者不想使用chnroutes这样和autoproxy相比不精确的方法,怎么办呢,下次我撰文写如何把VPN隧道转换成代理。请关注。

Author Info :