ssh隧道技术

来源:互联网 发布:php开源库存管理系统 编辑:程序博客网 时间:2024/04/30 06:19

干什么用的:

A机器ssh到B机器, 创建一个隧道, 通过这个隧道, A机器可以访问任何B机器能访问到的端口,  (这个称为本地转发)

或者反过来, 通过这个隧道, B机器可以访问到A机器能访问的任何端口, (这个称为远程转发)


实现方式:

1. 本地转发:

在A机器上执行命令:

ssh -L [bind_address:]port:host:hostport  userB@ipB

其中 bind_address只能为localhost或者*, 填其他没有意义

这时在A上另外开一个shell, 所有connect bind_address:port 的连接, 都会通过B机器 连接到 host:hostport


2. 远程转发

在A机器上执行

ssh -R [bind_address:]port:host:hostport userB@ipB

这时, 在B上, 所有connect bind_address:port的连接, 都会通过A机器, 连接到host:hostport


其实感觉man ssh上面说的更清楚, 但是百度上一直各种以讹传讹, 写个帖子希望有人能看到

附man ssh:

     -L [bind_address:]port:host:hostport
             Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side.
             This works by allocating a socket to listen to port on the local side, optionally bound to the specified bind_address.
             Whenever a connection is made to this port, the connection is forwarded over the secure channel, and a connection is made
             to host port hostport from the remote machine.  Port forwardings can also be specified in the configuration file. 

 -R [bind_address:]port:host:hostport
             Specifies that the given port on the remote (server) host is to be forwarded to the given host and port on the local side.
             This works by allocating a socket to listen to port on the remote side, and whenever a connection is made to this port,
             the connection is forwarded over the secure channel, and a connection is made to host port hostport from the local
             machine.


原创粉丝点击
热门问题 老师的惩罚 人脸识别 我在镇武司摸鱼那些年 重生之率土为王 我在大康的咸鱼生活 盘龙之生命进化 天生仙种 凡人之先天五行 春回大明朝 姑娘不必设防,我是瞎子 小孩在外地读书怎么办计生证明 泉州居住证要半年小孩读书怎么办 孩子上学有兰山户口没有房产怎么办 培训机构跑路了怎么办 报的培训班跑路怎么办 巡视组举报后会怎么办 巡视组交办不办怎么办 分手以后还要不要联系忘不了怎么办 父母穷且不上进怎么办 惹父母生气了该怎么办 小孩戒奶不吃奶粉怎么办 孩子听不进去话怎么办 异性好朋友喜欢自己亲吻自己怎么办 对方对你反感了怎么办 家长偷看孩子日记老师怎么办 儿子与父母相冲怎么办 初二孩子不争气老师打他怎么办? 孩子被老师打又怎么办 家里2个孩子打架怎么办 一年级的学生特别会顶嘴怎么办 私立学校的学生顶嘴老师该怎么办 孩子做错事家长不道歉怎么办 孩孑语文成绩差怎么办 高三了孩子不愿意补课怎么办 四年级的孩子上课喜欢讲小话怎么办 五年级孩子太叛逆怎么办 二年级话唠孩子怎么办 家有老人带孩子怎么办 不会看孩子。孩子一哭就害怕怎么办 孩子不老实爱动怎么办 4周孩子脾气大怎么办 老公脾气暴躁爱骂人怎么办? 当妈妈了脾气不好怎么办 父亲很坏不顾家很会赌钱怎么办 妈妈骂我很难听怎么办 父母管的太严怎么办 2岁宝宝哭闹不止怎么办 8岁儿童叛逆期怎么办 两岁宝宝叛逆期怎么办 4个月小孩哭怎么办 2个月孩子爱哭怎么办