@ユメイ7 年前
默认用户是pi 密码为raspberry 修改root密码 sudo passwd root
启用 root 账号登录
sudo passwd --unlock root
新版本ssh默认关闭root登陆 你可以修改一下ssh的配置文件
sudo nano /etc/ssh/sshd_config
PermitRootLogin without-password修改为PermitRootLogin yes
service ssh restart
更新系统apt-get dist-upgrade
官方初始化命令 sudo raspi-config
安装shadowsocks
- 安装 Python 的包管理工具 pip:
apt-get install python-pip python-m2crypto supervisor
- 安装 shadowsocks 客户端:
pip install https://github.com/shadowsocks/shadowsocks/archive/master.zip
- 新建
nano /home/pi/ss.json
内容如下:{ "server": "xxx.xxx.xxx.xxx", "server_port": 32768, "local_address": "0.0.0.0", "local_port": 1080, "password": "xxx", "timeout": 300, "method": "aes-256-cfb", "fast_open": true }
安装libsodium
编辑 /etc/supervisor/conf.d/shadowsocks.conf ,增加下面的内容:
[program:shadowsocks]
command=sslocal -c /home/pi/ss.json
autorestart=true
user=nobody
启动supervisor:
service supervisor start
supervisorctl reload
supervisorctl tail -f shadowsocks stderr //查看shadowsocks日志
supervisorctl restart shadowsocks //重启shadowsocks进程
supervisorctl start shadowsocks //启动shadowsocks进程
supervisorctl stop shadowsocks //停止shadowsocks进程
安装 polipo http代理:
apt-get install polipo
- 打开文件
/etc/polipo/config
,替换内容如下:proxyAddress = "0.0.0.0" socksParentProxy = "127.0.0.1:1080" socksProxyType = socks5 chunkHighMark = 50331648 objectHighMark = 16384 serverMaxSlots = 64 serverSlots = 16 serverSlots1 = 32
- 重启 polipo 服务:
/etc/init.d/polipo restart
编辑 /etc/supervisor/conf.d/polipo.conf ,增加下面的内容:
[program:shadowsocks]
command= polipo -c /etc/polipo/config pidFile=/var/run/polipo/polipo.pid
autorestart=true
user=nobody
加载bbr echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf sysctl -p
在nat表中创建一个SHADOWSOCKS项
sudo iptables -t nat -N SHADOWSOCKS sudo iptables -t nat -A SHADOWSOCKS -d sola.moe -j RETURN sudo iptables -t nat -A SHADOWSOCKS -d 0.0.0.0/8 -j RETURN sudo iptables -t nat -A SHADOWSOCKS -d 10.0.0.0/8 -j RETURN sudo iptables -t nat -A SHADOWSOCKS -d 127.0.0.0/8 -j RETURN sudo iptables -t nat -A SHADOWSOCKS -d 169.254.0.0/16 -j RETURN sudo iptables -t nat -A SHADOWSOCKS -d 172.16.0.0/12 -j RETURN sudo iptables -t nat -A SHADOWSOCKS -d 192.168.0.0/16 -j RETURN sudo iptables -t nat -A SHADOWSOCKS -d 224.0.0.0/4 -j RETURN sudo iptables -t nat -A SHADOWSOCKS -d 240.0.0.0/4 -j RETURN sudo iptables -t nat -A SHADOWSOCKS -p tcp -j REDIRECT --to-ports 1080 sudo iptables -t nat -A PREROUTING -p tcp -j SHADOWSOCKS sudo iptables -t nat -A OUTPUT -p tcp -j SHADOWSOCKS
保存iptable
iptables-save > /etc/iptables.conf
配置iptables,让其能在重启时自动动行并生效
编辑 /etc/network/if-pre-up.d/iptables,加入下面两行
#!/bin/sh
iptables-restore < /etc/iptables.conf
执行
chmod +x /etc/network/if-pre-up.d/iptables
bash /etc/network/if-pre-up.d/iptables
用命令测试一下iptables保存是否生效
iptables-save
打开nat
nano /etc/sysctl.conf
net.ipv4.ip_forward=1
实时生效sysctl -p