页面“Vps”与“Debian利用shadowsocks和polipo终端代理翻墙”之间的差异

来自linux中国网wiki
(页面间的差异)
跳到导航 跳到搜索
→‎2020
 
→‎apt
 
第1行: 第1行:
 +
= shadowsocks和polipo=
  
 +
终端翻墙的方法,通过shadowsocks和polipo来实现
  
=2020=
+
==安装shadowsocks==
多看一些相关的 评测和站点
+
安装python包管理工具:
 +
sudo apt-get install python-pip
  
还有要评测什么的
+
===apt===
 +
<pre>#apt
 +
sudo apt install software-properties-common -y
 +
#sudo add-apt-repository ppa:max-c-lv/shadowsocks-libev -y
 +
sudo apt update
  
[https://www.vultryhw.cn/vultr-speedtest/ Vultr各节点官方测速地址]
+
#apt安装的 试过不能用 ,得用pip安装的才行
 +
sudo apt install shadowsocks-libev 
  
洛杉矶 和硅谷还可以
+
vi /etc/shadowsocks-libev/config.json
 +
{
 +
"server":"127.0.0.1",
 +
"server_port":8388,
 +
"local_port":1080,
 +
"password":"focobguph",
 +
"timeout":60,
 +
"method":"chacha20-ietf-poly1305"
 +
}
  
=免费升级=
+
sudo systemctl enable shadowsocks-libev.service
  
==vultr ==
+
</pre>
servers -->settings -->change plan
+
 
 +
===pip===
 +
<pre>
 +
pip install shadowsocks
 +
#sudo pip install shadowsocks #格式有时不对,要小心
 +
vi shadowsocks.json#新建shadowsocks配置文件shadowsocks.json
 +
{
 +
"server": "xxx.xxx.xxx.xxx",
 +
"server_port": xxxx,
 +
"local_port": 1080,
 +
"password": "xxxxxxx",
 +
"timeout": 600,
 +
"method": "aes-256-cfb"
 +
}
 +
 
 +
eg
 +
 
 +
echo '{
 +
    "server":"linuxsh.org",
 +
    "server_port":443,
 +
    "local_port":1080,
 +
    "password":"laepassword",
 +
    "timeout":600,
 +
    "method":"aes-256-cfb"
 +
}' >shadowsocks.json </pre>
 +
 
 +
[https://www.linuxbabe.com/ubuntu/shadowsocks-libev-proxy-server-ubuntu-16-04-17-10 How to Set up Shadowsocks-libev Proxy Server on Ubuntu 16.04]
 +
 
 +
==安装polipo:==
 +
<pre>sudo apt-get install polipo -y
  
== digitalocean==
+
#修改polipo配置文件
--> resize -->Disk, CPU and RAM
+
echo 'logSyslog = true
 +
logFile = /var/log/polipo/polipo.log
 +
proxyAddress = "0.0.0.0"
 +
socksParentProxy = "127.0.0.1:1080"
 +
socksProxyType = socks5
 +
chunkHighMark = 50331648
 +
objectHighMark = 16384
 +
serverMaxSlots = 64
 +
serverSlots = 16
 +
serverSlots1 = 32' >/etc/polipo/config </pre>
  
<pre> #150这个样子
+
==启动服务==
evan@bsd-latop:~ % ping linuxchina.net
+
<pre>
PING linuxchina.net (138.197.220.125): 56 data bytes
+
#启动shadowsocks服务: 如果是pip inst
64 bytes from 138.197.220.125: icmp_seq=0 ttl=51 time=154.269 ms
+
sudo  sslocal -c /root/shadowsocks.json -d start
64 bytes from 138.197.220.125: icmp_seq=1 ttl=51 time=153.722 ms
+
#重启polipo服务:
64 bytes from 138.197.220.125: icmp_seq=2 ttl=51 time=153.646 ms
+
/etc/init.d/polipo restart
64 bytes from 138.197.220.125: icmp_seq=3 ttl=51 time=153.907 ms
+
设置http和https代理:
64 bytes from 138.197.220.125: icmp_seq=4 ttl=51 time=153.740 ms
+
export http_proxy="http://127.0.0.1:8123/"
64 bytes from 138.197.220.125: icmp_seq=5 ttl=51 time=152.701 ms
+
export https_proxy=$http_proxy
64 bytes from 138.197.220.125: icmp_seq=6 ttl=51 time=153.862 ms
 
  
 +
如果想长期 加到 /etc/profile
 +
 +
 +
cat >> /etc/profile <<EOF
 +
export http_proxy=http://127.0.0.1:8123
 +
export https_proxy=http://127.0.0.1:8123
 +
export ftp_proxy=http://127.0.0.1:8123
 +
EOF
 +
 +
source /etc/profile
 +
 +
#不要代理的 也要加进去
 +
export NO_PROXY='localhost,127.0.0.1,192.168.88.30,192.168.88.31,192.168.88.32,10.96.0.0,10.224.0.0,10.96.0.0/12,10.224.0.0/16'
 +
 +
 +
 +
 +
这里最好是gnome3 手工设置代理呢 如果你是有桌面的话
 +
 +
127.0.0.1 8123
 +
测试
 +
访问谷歌,若有反应则成功:
 +
w3m google.com
 +
curl www.google.com #但是502 很容易让人误会会不成功我一开始也是这样
 +
 +
这个在ubbuntu16.04 server 中是成功的 centos的要再看一下
  
在HK的机器好一点点
 
 
</pre>
 
</pre>
  
[https://www.zhihu.com/question/25529727 DigitalOcean 选择 Region 的问题?]
+
=浏览器=
 +
<pre>
  
 +
#本地apt shadowsock and then  ok 20190728 因为我本地的端口是7070
 +
chromium --proxy-server="http=socks5://127.0.0.1:1080"
 +
/opt/google/chrome/chrome --proxy-server="https=socks5://127.0.0.1:7070"
  
[https://digitalocean.youhuima.cc/digitalocean%e5%93%aa%e4%b8%aa%e6%9c%ba%e6%88%bf%e5%bf%ab%e5%92%8c%e7%a8%b3%e5%ae%9a.html Digitalocean哪个机房快和稳定]
 
  
 +
chromium --proxy-server="http=socks5://127.0.0.1:1080"
 +
chromium --proxy-server="https=socks5://127.0.0.1:1080"
 +
/opt/google/chrome/chrome --proxy-server="https=socks5://127.0.0.1:1080"
  
https://digitalocean.youhuima.cc/
+
chrominum-browser --proxy-server="https=socks5://127.0.0.1:1080"
 +
</pre>
 +
https://www.linuxdashen.com/%E5%9C%A8%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%B8%8B%E4%B8%BAchromium%E5%92%8Cgoogle-chrome%E6%B5%8F%E8%A7%88%E5%99%A8%E8%AE%BE%E7%BD%AE%E4%BB%A3%E7%90%86
  
这些不错, 过有点小贵
+
=gnome 全局=
http://www.ehostidc.cn
 
  
国内到韩国的网络线路,应该是最好的,甚至可以媲美中国国内的双线机房。
+
network proxy
 +
HTTP 127.0.0.1  8123
 +
HTTPS 127.0.0.1 8123
 +
这样就可以全局翻墙 然后 安装上chrome 扩展
  
<pre>北京联通 ping zyan.cc:
+
=SS+PAC=
root@linaro-alip:~# ping zyan.cc
+
[https://www.jianshu.com/p/11a3f84b6782 Manjaro17.0.1(xfce)+SS+PAC模式配置笔记]
PING zyan.cc (27.255.71.186) 56(84) bytes of data.
 
64 bytes from 27.255.71.186: icmp_req=1 ttl=50 time=68.3 ms</pre>
 
  
=aws  and  cloud.google=
+
= xfce=
  
==防火墙配置==
+
要看一下这个 上次就是终端可以 ss 但是浏览器不行
GCE 默认开启了防火墙且不能关闭,只能允许你自己指定的协议和端口的流量;经过我自己的实际测试,GCE 能够自动过滤相当的 DDOS 攻击流量。
+
[https://scalpel.vip/2017/03/06/xfceautoproxy/ Xfce桌面环境下通过pac实现自动代理]
  
由于防火墙不能关闭,所以不能配置类似 IPv6 Tunnel 的服务,所以导致目前的 GCE 是不能够支持 IPv6 的,不过相信以后 Google 还是会启用 IPv6 支持。
+
[https://github.com/yueyoum/myblogposts/blob/master/2013-01/%E4%B8%BAXfce4%E6%A1%8C%E9%9D%A2%E7%8E%AF%E5%A2%83%E8%AE%BE%E7%BD%AE%E5%85%A8%E5%B1%80%E4%BB%A3%E7%90%86.md 为Xfce4桌面环境设置全局代理]
  
在 “网络” 里,可以找到 [https://console.cloud.google.com/networking/firewalls/list 防火墙规则],然后可以 [https://console.cloud.google.com/networking/firewalls/add 添加防火墙规则]
+
[https://my.oschina.net/u/1444992/blog/600517 Xfce设置代理Proxy]
  
默认已经允许了 SSH 和 ICMP 等(以 default 开头的)
+
=trouble shooting=
  
=Billing=
+
  "timeout": 600,  这个记得不能设置太短 我一开始也是不可以的,后来改了几处,加上重启什么的 竟然就好了  可能是一开始就是好的呢
2018年 04月 30日 星期一 就算为5月一号 $10
 
  
2018年 09月 03日 星期一 10:18:48 CST $10 就是 70+70 rmb
+
==Kali2.0 update到最新版本后安装shadowsocks服务报错问题 用于解决openssl升级到1.1.0以上版本,导致shadowsocks2.8.2启动报undefined symbol: EVP_CIPHER_CTX_cleanup错误==
 +
<pre>
 +
最近将kali升级到了最新版本,编译之后shadowsocks无法启动,报错如下:
  
2018年 11月 02日  2019年 01月 02日 星期三
+
INFO: loading config from ss.json
2019年3.1   5.1给10刀
+
2016-12-14 22:47:50 INFO loading libcrypto from libcrypto.so.1.1
Mon Jul  1 13:37:10 UTC 2019
+
Traceback (most recent call last):
 +
File “/usr/local/bin/sslocal”, line 11, in
 +
sys.exit(main())
 +
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/local.py”, line 39, in main
 +
config = shell.get_config(True)
 +
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py”, line 262, in get_config
 +
check_config(config, is_local)
 +
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py”, line 124, in check_config
 +
encrypt.try_cipher(config[‘password’], config[‘method’])
 +
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py”, line 44, in try_cipher
 +
Encryptor(key, method)
 +
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py”, line 83, in init
 +
random_string(self._method_info[1]))
 +
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py”, line 109, in get_cipher
 +
return m[2](method, key, iv, op)
 +
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py”, line 76, in init
 +
load_openssl()
 +
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py”, line 52, in load_openssl
 +
libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
 +
File “/usr/lib/python2.7/ctypes/init.py”, line 375, in getattr
 +
func = self.getitem(name)
 +
File “/usr/lib/python2.7/ctypes/init.py”, line 380, in getitem
 +
func = self._FuncPtr((name_or_ordinal, self))
 +
AttributeError: /usr/lib/x86_64-Linux-gnu/libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup
  
2019年 9月 1日 星期日 13时19分13秒 CST 只先给了5刀
+
这个问题是由于在openssl1.1.0版本中,废弃了EVP_CIPHER_CTX_cleanup函数,如官网中所说:
  
Wed 06 Nov 2019
+
EVP_CIPHER_CTX was made opaque in OpenSSL 1.1.0. As a result, EVP_CIPHER_CTX_reset() appeared and EVP_CIPHER_CTX_cleanup() disappeared.
digita
+
EVP_CIPHER_CTX_init() remains as an alias for EVP_CIPHER_CTX_reset().
$3.33  Remaining
 
  
用了 $7.36 应该可以到12月才 给钱
+
修改方法:
  
2019年12月 1日
+
# pip install
 +
用vim打开文件:vim /usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py (该路径请根据自己的系统情况自行修改,如果不知道该文件在哪里的话,可以使用find命令查找文件位置)
 +
跳转到52行(shadowsocks2.8.2版本,其他版本搜索一下cleanup)
 +
进入编辑模式
 +
将第52行libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,)
 +
改为libcrypto.EVP_CIPHER_CTX_reset.argtypes = (c_void_p,)
 +
再次搜索cleanup(全文件共2处,此处位于111行),将libcrypto.EVP_CIPHER_CTX_cleanup(self._ctx)
 +
改为libcrypto.EVP_CIPHER_CTX_reset(self._ctx)
 +
保存并退出
 +
启动shadowsocks服务:service shadowsocks start 或 sslocal -c ss配置文件目录
  
 +
</pre>
  
2020年 1月28日 星期二  digio 5刀 ;  vultr没理
+
=see also=
 
 
=ec2=
 
aws web用firefox打开 不然好慢
 
=google=
 
cloud.google.com
 
  
2019.02.06 过期
+
[https://www.jianshu.com/p/c30c1e7b90cf Ubuntu16.04 终端翻墙]
  
=SEE ALSO=
+
[https://blog.itnmg.net/2016/04/30/shadowsocks/ CentOS 7 安装 Shadowsocks 科学上网]
  
[https://guozeyu.com/2016/10/asia-google-compute-engine/ Google Compute Engine 新手教程]
+
[http://forum.ubuntu.org.cn/viewtopic.php?t=291484 在xfce下的chrome浏览器如何设置代理服务器?(已解决,换浏览器)]
  
[https://blog.51cto.com/wzlinux/2382381 国外 VPS 购买列表]
 
  
 +
[https://blog.fazero.me/2015/09/15/%E8%AE%A9%E7%BB%88%E7%AB%AF%E8%B5%B0%E4%BB%A3%E7%90%86%E7%9A%84%E5%87%A0%E7%A7%8D%E6%96%B9%E6%B3%95/ 让终端走代理的几种方法]
  
[https://github.com/wuyao721/51docs/blob/master/it/aws-ec2-price.org 亚马逊EC2收费笔记]
+
[http://adagio-cantabile.github.io/2016/12/06/install-shadowsocks-in-ubuntu.html 如何在ubuntu16通过终端设置shadowsocks实现科学上网]
  
[https://cloud.google.com/compute/docs/instances/connecting-to-instance#standardssh 连接到 Linux 实例]
 
  
[https://cloud.google.com/compute/pricing?hl=zh_CN&_ga=2.171515555.-221994790.1518005746 Google Compute Engine 价格]
+
[https://www.digitalocean.com/community/tutorials/how-to-route-web-traffic-securely-without-a-vpn-using-a-socks-tunnel How To Route Web Traffic Securely Without a VPN Using a SOCKS Tunnel]
  
[[category:ops]] [[category:linux]]
+
[[category:linux]] [[category:ops]]

2020年2月29日 (六) 06:22的版本

shadowsocks和polipo

终端翻墙的方法,通过shadowsocks和polipo来实现

安装shadowsocks

安装python包管理工具:

sudo apt-get install python-pip

apt

#apt 
sudo apt install software-properties-common -y
#sudo add-apt-repository ppa:max-c-lv/shadowsocks-libev -y
sudo apt update

#apt安装的 试过不能用 ,得用pip安装的才行 
sudo apt install shadowsocks-libev  

vi /etc/shadowsocks-libev/config.json
{
 "server":"127.0.0.1",
 "server_port":8388,
 "local_port":1080,
 "password":"focobguph",
 "timeout":60,
 "method":"chacha20-ietf-poly1305"
}

sudo systemctl enable shadowsocks-libev.service

pip

pip install shadowsocks
#sudo pip install shadowsocks #格式有时不对,要小心
vi shadowsocks.json#新建shadowsocks配置文件shadowsocks.json
{
"server": "xxx.xxx.xxx.xxx",
"server_port": xxxx,
"local_port": 1080,
"password": "xxxxxxx",
"timeout": 600,
"method": "aes-256-cfb"
}

eg

echo '{
    "server":"linuxsh.org",
    "server_port":443,
    "local_port":1080,
    "password":"laepassword",
    "timeout":600,
    "method":"aes-256-cfb"
}' >shadowsocks.json 

How to Set up Shadowsocks-libev Proxy Server on Ubuntu 16.04

安装polipo:

sudo apt-get install polipo -y

#修改polipo配置文件
echo 'logSyslog = true
logFile = /var/log/polipo/polipo.log
proxyAddress = "0.0.0.0"
socksParentProxy = "127.0.0.1:1080"
socksProxyType = socks5
chunkHighMark = 50331648
objectHighMark = 16384
serverMaxSlots = 64
serverSlots = 16
serverSlots1 = 32' >/etc/polipo/config 

启动服务

#启动shadowsocks服务: 如果是pip inst
sudo  sslocal -c /root/shadowsocks.json -d start
#重启polipo服务:
 /etc/init.d/polipo restart
设置http和https代理:
export http_proxy="http://127.0.0.1:8123/"
export https_proxy=$http_proxy 

如果想长期 加到 /etc/profile


cat >> /etc/profile <<EOF
export http_proxy=http://127.0.0.1:8123
export https_proxy=http://127.0.0.1:8123
export ftp_proxy=http://127.0.0.1:8123
EOF

 source /etc/profile

#不要代理的 也要加进去
export NO_PROXY='localhost,127.0.0.1,192.168.88.30,192.168.88.31,192.168.88.32,10.96.0.0,10.224.0.0,10.96.0.0/12,10.224.0.0/16'




这里最好是gnome3 手工设置代理呢 如果你是有桌面的话

127.0.0.1 8123
测试
访问谷歌,若有反应则成功:
w3m google.com
curl www.google.com #但是502 很容易让人误会会不成功我一开始也是这样

这个在ubbuntu16.04 server 中是成功的 centos的要再看一下

浏览器


#本地apt shadowsock and then  ok 20190728 因为我本地的端口是7070
chromium --proxy-server="http=socks5://127.0.0.1:1080"
/opt/google/chrome/chrome --proxy-server="https=socks5://127.0.0.1:7070"


chromium --proxy-server="http=socks5://127.0.0.1:1080"
chromium --proxy-server="https=socks5://127.0.0.1:1080"
/opt/google/chrome/chrome --proxy-server="https=socks5://127.0.0.1:1080"

chrominum-browser --proxy-server="https=socks5://127.0.0.1:1080"

https://www.linuxdashen.com/%E5%9C%A8%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%B8%8B%E4%B8%BAchromium%E5%92%8Cgoogle-chrome%E6%B5%8F%E8%A7%88%E5%99%A8%E8%AE%BE%E7%BD%AE%E4%BB%A3%E7%90%86

gnome 全局

network proxy HTTP 127.0.0.1 8123 HTTPS 127.0.0.1 8123 这样就可以全局翻墙 然后 安装上chrome 扩展

SS+PAC

Manjaro17.0.1(xfce)+SS+PAC模式配置笔记

xfce

要看一下这个 上次就是终端可以 ss 但是浏览器不行 Xfce桌面环境下通过pac实现自动代理

为Xfce4桌面环境设置全局代理

Xfce设置代理Proxy

trouble shooting

"timeout": 600,  这个记得不能设置太短 我一开始也是不可以的,后来改了几处,加上重启什么的 竟然就好了  可能是一开始就是好的呢

Kali2.0 update到最新版本后安装shadowsocks服务报错问题 用于解决openssl升级到1.1.0以上版本,导致shadowsocks2.8.2启动报undefined symbol: EVP_CIPHER_CTX_cleanup错误

最近将kali升级到了最新版本,编译之后shadowsocks无法启动,报错如下:

INFO: loading config from ss.json 
2016-12-14 22:47:50 INFO loading libcrypto from libcrypto.so.1.1 
Traceback (most recent call last): 
File “/usr/local/bin/sslocal”, line 11, in 
sys.exit(main()) 
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/local.py”, line 39, in main 
config = shell.get_config(True) 
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py”, line 262, in get_config 
check_config(config, is_local) 
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/shell.py”, line 124, in check_config 
encrypt.try_cipher(config[‘password’], config[‘method’]) 
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py”, line 44, in try_cipher 
Encryptor(key, method) 
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py”, line 83, in init 
random_string(self._method_info[1])) 
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/encrypt.py”, line 109, in get_cipher 
return m[2](method, key, iv, op) 
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py”, line 76, in init 
load_openssl() 
File “/usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py”, line 52, in load_openssl 
libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,) 
File “/usr/lib/python2.7/ctypes/init.py”, line 375, in getattr 
func = self.getitem(name) 
File “/usr/lib/python2.7/ctypes/init.py”, line 380, in getitem 
func = self._FuncPtr((name_or_ordinal, self)) 
AttributeError: /usr/lib/x86_64-Linux-gnu/libcrypto.so.1.1: undefined symbol: EVP_CIPHER_CTX_cleanup

这个问题是由于在openssl1.1.0版本中,废弃了EVP_CIPHER_CTX_cleanup函数,如官网中所说:

EVP_CIPHER_CTX was made opaque in OpenSSL 1.1.0. As a result, EVP_CIPHER_CTX_reset() appeared and EVP_CIPHER_CTX_cleanup() disappeared. 
EVP_CIPHER_CTX_init() remains as an alias for EVP_CIPHER_CTX_reset().

修改方法:

# pip install
用vim打开文件:vim /usr/local/lib/python2.7/dist-packages/shadowsocks/crypto/openssl.py (该路径请根据自己的系统情况自行修改,如果不知道该文件在哪里的话,可以使用find命令查找文件位置)
跳转到52行(shadowsocks2.8.2版本,其他版本搜索一下cleanup)
进入编辑模式
将第52行libcrypto.EVP_CIPHER_CTX_cleanup.argtypes = (c_void_p,) 
改为libcrypto.EVP_CIPHER_CTX_reset.argtypes = (c_void_p,)
再次搜索cleanup(全文件共2处,此处位于111行),将libcrypto.EVP_CIPHER_CTX_cleanup(self._ctx) 
改为libcrypto.EVP_CIPHER_CTX_reset(self._ctx)
保存并退出
启动shadowsocks服务:service shadowsocks start 或 sslocal -c ss配置文件目录

see also

Ubuntu16.04 终端翻墙

CentOS 7 安装 Shadowsocks 科学上网

在xfce下的chrome浏览器如何设置代理服务器?(已解决,换浏览器)


让终端走代理的几种方法

如何在ubuntu16通过终端设置shadowsocks实现科学上网


How To Route Web Traffic Securely Without a VPN Using a SOCKS Tunnel