ssh 端口转发

陌路散爱 提交于 2020-08-13 13:42:07
# 本地转发,正向代理,使用本地端口访问远程端口
# <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 <local host>:<local port> <user>@<hostname>
# ~/.ssh/config
Host server
    HostName <hostname>
    User <user>
    DynamicForward <local host>:<local port>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!