介绍

本文是一个笔记,记录了用使用danted-server搭建socks5代理,使用用户名和密码,并应用在github上,提高clone,push,pull的速度。

步骤

购买海外服务器

可以在aliyun上购买国外服务器,安装ubuntu18.04

安装并配置danted

安装命令

1
2
3
4
apt update 
apt install dante-server
mkdir /var/log/danted/
vi /etc/danted.conf

/etc/danted.conf内容

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
logoutput: syslog stdout /var/log/danted/danted.log
user.privileged: root
user.unprivileged: nobody
# desired proxy ports may differ, used here: POP3 110, IMAP 143, HTTPS 443
internal: 0.0.0.0 port = 1080
# interface name may differ, use `ip a` command and copy non-lo interface:
external: eth0
# set socksmethod to 'none' instead of 'username' if you want to disable auth.
socksmethod: username
clientmethod: none
user.libwrap: nobody
client pass {
        from: 0/0 to: 0/0
}
socks pass {
        from: 0/0 to: 0/0
}

添加用户

1
2
3
useradd -r -s /bin/false dproxy
passwd dproxy
# 输入 123456

重启danted

1
2
3
service danted restart
netstat -nap|grep 1080 #查看端口是否起来
# tcp        0      0 0.0.0.0:1080            0.0.0.0:*               LISTEN

防火墙配置

1
2
3
4
5
ufw allow 22
ufw allow 1080
ufw enable
# 输入 y
ufw status

查看aliyun或其他云平台的安全组。

将1080端口设置为可访问。

.gitconfig配置(本地文件)

1
vi ~/.gitconfig

添加

1
2
3
4
5
...
[http "https://github.com"]
	proxy = socks5://dproxy:123456@serverip:6010
[https "https://github.com"]
	proxy = socks5://dproxy:123456@serverip:6010

serverip替换为服务器外网ip

查看danted日志

1
tail -f /var/log/danted/danted.log