BlueXIII's Blog

热爱技术,持续学习

0%

反向SSH隧道

参考文档

命令行

1
2
3
4
# 映射yum源
ssh -R 8081:127.0.0.1:8081 -p2203 root@192.168.23.14
# 映射socks5
ssh -R 7890:127.0.0.1:8118 -p2203 root@192.168.23.14

服务器开启gatewayport

服务器端开启gatewayport后,局域网内其它机器可共享此端口

1
2
vi /etc/ssh/sshd_config
GatewayPorts yes

本机开启临时yum服务

1
2
cd ~/opt/yum
http-server

服务器配置yum源指向

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
cp -R /etc/yum.repos.d /etc/yum.repos.d.bak2

cat << EOF >>/etc/yum.repos.d/CentOS-Remote.repo
[centos7]
name=centos7
baseurl=http://127.0.0.1:8081/centos7
enabled=1
gpgcheck=0

[epel]
name=epal
baseurl=http://127.0.0.1:8081/epel
enabled=1
gpgcheck=0
EOF

yum clean all && yum makecache

本机socks5转http

解决clash的mix端口兼容性问题

1
2
3
4
5
6
7
brew install privoxy

vi /usr/local/etc/privoxy/config
listen-address localhost:8118
forward-socks5t / 127.0.0.1:7890 .

brew services start privoxy

ClashX直接开启http端口(废弃)

解决clash的mix端口兼容性问题,但7892http端口依然无效

1
2
3
vi ~/.config/clash/config.yaml
socks-port: 7891
port: 7892

导入全局代理环境变量

1
2
3
4
5
6
# 导入代理环境变量
export https_proxy=http://127.0.0.1:8118 http_proxy=http://127.0.0.1:8118 all_proxy=http://127.0.0.1:8118


# 测试
curl cip.cc

yum单独配代理

1
2
3
4
5
6
vi /etc/yum.conf
proxy=http://127.0.0.1:7890

# 禁用搜索最快镜像,避免卡顿
vi /etc/yum/pluginconf.d/fastestmirror.conf
enabled=0

docker单独配代理

1
2
3
4
5
6
7
8
mkdir -p /etc/systemd/system/docker.service.d
cat << EOF >>/etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:7890" "HTTPS_PROXY=http://127.0.0.1:7890" "NO_PROXY=localhost,127.0.0.1"
EOF

systemctl daemon-reload && systemctl restart docker
systemctl show --property=Environment docker

proxychains强行走代理

1
2
3
4
5
6
7
8
9
10
11
12
# 下载并编译
git clone https://github.com/rofl0r/proxychains-ng
./configure
make && make install && make install-config

# 修改配置文件
vi /usr/local/etc/proxychains.conf
[ProxyList]
socks5 127.0.0.1 7890

# 测试
proxychains4 wget www.baidu.com

localhost.run

https://localhost.run/