ssh 端口转发
# 本地转发,正向代理,使用本地端口访问远程端口 # <user>@<hostname> 为跳板机,不一定要和 <remote host> 一致 ssh -L <local host>:<local port>:<remote host>:<remote port> <user>@<hostname> # ~/.ssh/config Host server HostName <hostname> User <user> LocalForward <local host>:<local port> <remote host>:<remote port> # 远程转发,反向代理,使用远程端口访问本地端口 # 远程主机 /etc/ssh/sshd_config 需要设置 GatewayPorts yes 否则仅远程本地可访问 ssh -R <remote host>:<remote port>:<local host>:<local port> <user>@<hostname> # ~/.ssh/config Host server HostName <hostname> User <user> RemoteForward <remote host>:<remote port> <local host>:<local port> # 动态转发,SOCKS5 代理, ssh -D