当前位置:网站首页>内网服务器访问远程服务器的端口映射
内网服务器访问远程服务器的端口映射
2022-08-04 03:07:00 【junjunzai123】
映射命令
# 命令格式
ssh -R <local port>:<remote host>:<remote port> <SSH hostname>
命令说明:
在本地这台机器上监听一个端口,然后所有访问这个端口的数据都会通过ssh 隧道传输到远端的对应端口上.
本地端口转发绑定的是 lookback 接口,这意味着只有 localhost 或者 127.0.0.1 才能使用本机的端口转发 , 其他机器发起的连接只会得到“ connection refused. ”。要想让其他机器也能共享这个隧道来转发的话需要在配置文件中使用GatewayPorts 关键字,或者直接命令行下使用"-g"参数。
另外本地转发命令中的 <remote host> 和 <SSH hostname> 可以是不同的主机
ssh的三个强大的端口转发命令:
转发到远端:ssh -C -f -N -g -L 本地端口:目标IP:目标端口 用户名@目标IP
转发到本地:ssh -C -f -N -g –R 本地端口:目标IP:目标端口 用户名@目标IP
ssh -C -f -N -g -D listen_port [email protected]_Host
参数说明:-C,是进行数据压缩。 -f,是后台认证用户/密码,通常和-N连用,不用登录到远程主机。只有当提示用户名密码的时候才转向前台。 -N,是不执行远端命令,在只是端口转发时这条命令很有用处。 -g ,在-L/-R/-D参数中,是允许远端主机连接本地转发端口,如果不加这个参数,只允许本地主机建立连接。 -L,则是将本地端口映射到远端主机端口。本地端口:目标IP:目标端口 将本地机(客户机)的某个端口转发到远端指定机器的指定端口。 工作原理: 本地机器上分配了一个 socket 侦听 port 端口, 一旦这个端口上有连接, 该连接就经过安全通道转发出去, 同时远程主机和 host 的 hostport 端口建立连接. 可以在配置文件中指定端口的转发。 只有 root 才能转发特权端口。IPv6 地址用另一种格式说明: port/host/hostport -R,表明是将远端主机端口映射到本地端口。本地端口:目标IP:目标端口 将远程主机(服务器)的某个端口转发到本地端指定机器的指定端口 工作原理: 远程主机上分配了一个 socket 侦听 port 端口, 一旦这个端口上有连接, 该连接就经过安全通道转向出去, 同时本地主机和 host 的 hostport 端口建立连接. 可以在配置文件中指定端口的转发.。 只有用 root 登录远程主机才能转发特权端口.。IPv6 地址用另一种格式说明: port/host/hostport -D port 指定一个本地机器 “动态的\'’ 应用程序端口转发.。 工作原理: 本地机器上分配了一个 socket 侦听 port 端口, 一旦这个端口上有了连接, 该连接就经过安全通道转发出去, 根据应用程序的协议可以判断出远程主机将和哪里连接.。目前支持 SOCKS4 协议, 将充当 SOCKS4 服务器。 只有 root 才能转发特权端口,可以在配置文件中指定动态端口的转发。
实例说明
# 表示将远程服务183.242.xx.xx的8080端口映射到本地机器的8080端口, 本地映射之后使用localhost或是127.0.0.1, 这条命令需要在本地机器上执行
ssh -f -N -L 8080:localhost:8080 [email protected]183.242.xx.xx -p 2022
- 映射之后进行登录
- 使用jupyter举例, 在浏览器中输入: localhost:8080,即可登录, 前提已经设置好密码登录模式.
边栏推荐
- 6-port full Gigabit Layer 2 network managed industrial Ethernet switch Gigabit 2 optical 4 electrical fiber self-healing ERPS ring network switch
- 查看mysql死锁语法
- There are too many systems, how to realize multi-account interworking?
- Brush esp8266-01 s firmware steps
- "Introduction to nlp + actual combat: Chapter 8: Using Pytorch to realize handwritten digit recognition"
- 【观察】超聚变:首提“算网九阶”评估模型,共建开放繁荣的算力网络
- There are n steps in total, and you can go up to 1 or 2 steps each time. How many ways are there?
- STM8S project creation (STVD creation) --- use COSMIC to create a C language project
- typescript type 和 interface 的区别
- What is the source of flinkcdc consuming mysql binlog data without sqltype=delete
猜你喜欢

融云「音视频架构实践」技术专场【内含完整PPT】

如何在MySQL中的数据库下删除所有的表

C语言--环形缓存区

Hey, I had another fight with HR in the small group!

y86.第四章 Prometheus大厂监控体系及实战 -- prometheus存储(十七)

Brush esp8266-01 s firmware steps

6-port full Gigabit Layer 2 network managed industrial Ethernet switch Gigabit 2 optical 4 electrical fiber self-healing ERPS ring network switch
SQL injection in #, - +, - % 20, % 23 is what mean?

sqoop ETL tool

STM8S项目创建(STVD创建)---使用 COSMIC 创建 C 语言项目
随机推荐
共n级台阶,每次可以上1级或2级台阶,有多少种上法?
哎,又跟HR在小群吵了一架!
如果禁用了安全启动,GNOME 就会发出警告
Countdown to 2 days, the "New Infrastructure of Cultural Digital Strategy and Ecological Construction of Cultural Art Chain" will kick off soon
Good bosses, please ask the flink CDC oracle to Doris, found that the CPU is unusual, a run down
出现504怎么办?由于服务器更新导致的博客报504错误[详细记录]
自定义通用分页标签02
全网没有之一的JMeter 接口测试流程详解
[QNX Hypervisor 2.2 User Manual] 10.3 vdev gic
[Original] Start the XPS/OXPS reader that comes with Windows 10
Utilities of Ruineng Micrometer Chip RN2026
一文看懂推荐系统:召回05:矩阵补充、最近邻查找,工业界基本不用了,但是有助于理解双塔模型
Zabbix set up email alert + enterprise WeChat alert
一文看懂推荐系统:召回04:离散特征处理,one-hot编码和embedding特征嵌入
db2中kettle报错 Field [XXX] is required and couldn‘t be found 解决方法
Hey, I had another fight with HR in the small group!
Mockito单元测试
【观察】超聚变:首提“算网九阶”评估模型,共建开放繁荣的算力网络
4-way two-way HDMI integrated business high-definition video optical transceiver 8-way HDMI high-definition video optical transceiver
Development of Taurus. MVC WebAPI introductory tutorial 1: download environment configuration and operation framework (including series directory).