CentOS6零基础配置shadowsocks服务端完整教程

shadowsocks 是一个轻量级隧道 socks5 代理,可加密网络通道。
项目主页:https://github.com/clowwindy/shadowsocks
官方wiki:https://github.com/clowwindy/shadowsocks/wiki/Shadowsocks

说明:
此教程为官方wiki补充,并附带M2Crypto、gevent 安装的详细说明,以便于零基础用户配置 shadowsocks 服务端。
此处以云睿数据(http://cloreal.net)的廉价VPS举例…
系统 CentOS6.5 x86_64,内建Python版本2.6.6(可使用 python -V 命令查看)

准备工作:安装所需组件

yum install wget tar gcc gcc-c++ openssl openssl-devel pcre-devel python-devel libevent -y

一、升级python
1、按以下步骤执行

cd /root
wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tgz
tar zxvf Python-2.7.6.tgz
cd Python-2.7.6
./configure
make & make install

2、设置python2.7.6为默认版本,此处python2.6.6为系统内建版本,不知道当前版本的可以使用 python -V 命令查看

mv /usr/bin/python /usr/bin/python2.6.6
ln -s /usr/local/bin/python2.7 /usr/bin/python
修改完毕后可以 python -V 查看一下是否成功

3、由于yum依赖内建python,所以需要修改一下yum依赖

vi /usr/bin/yum
说明:按 i 进入编辑模式,将第一行#!/usr/bin/python 改为 #!/usr/bin/python2.6.6,后者为内建python版本,然后按esc退出编辑模式,按shift+: ,输入wq保存文件即可~

二、安装pip
1、安装setuptools(pip需要这个),依次执行

cd /root
wget http://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg –no-check-certificate
sh setuptools-0.6c11-py2.7.egg

如果提示 zipimport.ZipImportError: can’t decompress data; zlib not available ,说明需要安装zlib库

cd /root/Python-2.7.6/Modules/zlib
./configure
make & make install

重新编译一下python

cd /root/Python-2.7.6
make & make install

安装setuptools

cd /root
sh setuptools-0.6c11-py2.7.egg

2、安装pip

cd /root
wget http://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz –no-check-certificate
tar zxvf pip-1.5.4.tar.gz
cd pip-1.5.4
python setup.py install

三、安装shadowsocks
由于安装了pip所以很简单了,一行命令的事

pip install shadowsocks

此时不推荐运行shadowsocks

四、安装M2Crypto
shadowsocks支持以下加密方式:

aes-128-cfb、aes-192-cfb、aes-256-cfb、bf-cfb、camellia-128-cfb、camellia-192-cfb、camellia-256-cfb、cast5-cfb、des-cfb、idea-cfb、rc2-cfb、rc4、seed-cfb、table

默认加密方法 table 速度很快,但很不安全,推荐使用 “aes-256-cfb” 或者 “bf-cfb”,使用加密必须安装M2Crypto。

1、安装swig
yum里swig版本太旧,如果使用yum安装基本上都是被坑的,如果系统集成大多也会有同样的问题
首先查看swig版本,如果是1.x版的先卸载掉

swig -version

执行以下命令

cd /root
wget http://jaist.dl.sourceforge.net/project/swig/swig/swig-3.0.0/swig-3.0.0.tar.gz
tar zxvf swig-3.0.0.tar.gz
cd swig-3.0.0
./configure
make & make install

安装完成后可以查看一下版本

swig -version

2、安装M2Crypto

cd /root
wget https://pypi.python.org/packages/source/M/M2Crypto/M2Crypto-0.22.3.tar.gz –no-check-certificate
tar zxvf M2Crypto-0.22.3.tar.gz
cd M2Crypto-0.22.3
python setup.py build
python setup.py install

五、安装Gevent
安装Gevent可以获得更好的性能,不管效果怎样,还是装个吧…
1、安装easy_install并安装greenlet

cd /root
wget -q http://peak.telecommunity.com/dist/ez_setup.py
python ez_setup.py
easy_install greenlet

2、安装Gevent(小内存VPS上可能无法通过)

cd /root
wget http://pypi.python.org/packages/source/g/gevent/gevent-0.13.8.tar.gz
tar zxvf gevent-0.13.8.tar.gz
cd gevent-0.13.8
python setup.py build
python setup.py install

六、运行shadowsocks
1、任意目录下建立一个名为“config.json”的文件,并编辑文本

touch config.json
vi config.json

2、设置shadowsocks服务端,按i进入编辑,将以下内容输入到文本中,编辑完成后按Esc退出编辑,然后Shift+:,输入wq保存

{
“server”:”my_server_ip”,
“server_port”:1024,
“local_port”:1989,
“password”:”lolicon”,
“timeout”:600,
“method”:”aes-256-cfb”
}

各字段的含义:

server 服务器 IP (IPv4/IPv6),注意这也将是服务端监听的 IP 地址
server_port 服务器端口
local_port 本地端端口
password 用来加密的密码
timeout 超时时间(秒)
method 加密方法,可选择 “bf-cfb”, “aes-256-cfb”, “des-cfb”, “rc4”, 等等。默认是一种不安全的加密,推荐用 “aes-256-cfb”

3、在config.json文件所在目录执行

ssserver (前台运行)
nohup ssserver > log & (后台一直运行)

4、如果成功运行,但是无法连接,可能是iptables设置问题,可以选择添加当前端口到白名单或关闭iptables解决

请将“1024”改为你所设置的服务器端口
iptables -I INPUT -p tcp -m tcp –dport 1024 -j ACCEPT
service iptables save (建议)
或者关闭iptables(不建议)
/etc/rc.d/init.d/iptables stop

5、客户端设置网上一搜一大把,就不赘述了…
Windows客户端:https://github.com/clowwindy/shadowsocks-csharp
Android客户端:https://play.google.com/store/apps/details?id=com.github.shadowsocks

 

—————————————————–

转载随意,修改随意,但请注明来源链接

引用:http://hazelzhu.com/archives/1568

还有谁能拯救我的Grive

CentOS 6.5 on Linode

# grive -a

grive: Symbol `json_tokener_errors' has different size in shared object, consider re-linking

-----------------------

Please go to this URL and get an authentication code:

https://accounts.google.com/o/oauth2/auth?*hidden*

-----------------------
Please input the authentication code here:
*hidden*
Reading local directories
Synchronizing folders
exception: /root/rpmbuild/BUILD/grive/libgrive/src/protocol/AuthAgent.cc(174): Throw in function long int gr::AuthAgent::CheckHttpResponse(long int, const std::string&, const gr::http::Header&)
Dynamic exception type: N5boost16exception_detail10clone_implIN2gr4http5ErrorEEEstd::exception::what: std::exception
[PN2gr4http15HttpResponseTagE] = 400
[PN2gr4http6UrlTagE] = https://docs.google.com/feeds/default/private/full/-/folder?max-results=50&showroot=true
[PN2gr4http9HeaderTagE] = Authorization: Bearer *hidden*
GData-Version: 3.0