ssh/Tunnel

ssh/Tunnel

Config

vim /etc/ssh/sshd_config

AllowAgentForwarding yes
AllowTcpForwarding yes
GatewayPorts yes

SSH Tunnel

ssh 支持很灵活的 tcp 端口转发

server: ssh 服务器端
local: ssh client 端

# server 21 => local => 1.2.3.4:443 (除非服务器端的 sshd_config 里配置了 GatewayPorts yes,否则 server 端只接受127.0.0.1发起的连接)
ssh -R 21:1.2.3.4:443 server

# server 1080 -> local localhost:1080
ssh -R 1080:localhost:1080 root@192.168.1.2

# local 1080 => server => intra.example.com:80 (by default anyone can connect to local 1080, unless specified with 127.0.0.1: prefix)
ssh -L 1080:intra.example.com:80 server

# local 127.0.0.1:1081 socket5 server => server => internet
ssh -D 1081 server

# local 0.0.0.0:1081 socket5 server => server => internet
ssh -D 0.0.0.0:1081 server

只需要 ssh 端口转发,不需要连接终端时,加上 ssh 的 -nNT 参数。


Last update: 2022-12-01 07:52:02 UTC