首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >配置文件反向隧道

问配置文件反向隧道
EN

Server Fault用户
提问于 2020-01-21 15:15:47
回答 1查看 2.3K关注 0票数 0

我正在寻找一个ssh客户端配置指令,如LocalForward,它作为-L CLI参数工作,但用于-R参数

TL;DR问题的全部细节

数据

repoServer -> myComputer -> NAT -> stagingServer

我有一个本地的git存储库服务器,它不公开在互联网上,还有一个远程的临时服务器,我必须在它上部署我的回购。

为此,我使用反向套接字进入远程stagingServer。

myComputer的当前配置:

文件:~/.ssh/config

代码语言:javascript
复制
Host StagingServer
  Hostname staging.acme.com
  User username
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_username
  ForwardAgent yes

我运行的内容:ssh StagingServer -R 8022:repository.local:22

stagingServer的当前配置:

文件:~/.ssh/config

代码语言:javascript
复制
Host repository
  Hostname localhost
  User git
  Port 8022
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_deployer

我可以在上面运行:git clone git@repository:myProject.git

一切都很好但是..。最后

问题

是否可以在ssh客户端配置文件(~/.ssh/ config )中指定打开反向隧道,以避免添加-R 8022:repository.local:22

EN

回答 1

Server Fault用户

回答已采纳

发布于 2020-01-21 15:25:06

显然,您要寻找的是RemoteForward,您可以在ssh_config文档中找到具体的.

文档:https://linux.die.net/man/5/ssh_配置 (搜索RemoteForward)。这是不言而喻的。

RemoteForward指定将远程计算机上的TCP端口通过安全通道从本地计算机转发到指定的主机和端口。第一个参数必须是绑定_地址:端口,第二个参数必须是host:hostport。IPv6地址可以通过将地址括在方括号中或使用另一种语法来指定:绑定_地址/地址端口和主机/主机端口。可以指定多个转发,并且可以在命令行上提供其他转发。只有以根用户身份登录远程计算机时,才能转发特权端口。

然后,myComputer的配置变成:

文件:~/.ssh/config

代码语言:javascript
复制
Host StagingServer
  Hostname staging.acme.com
  User username
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/id_username
  ForwardAgent yes
  RemoteForward 8022 repository.local:22
票数 1
EN
页面原文内容由Server Fault提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://serverfault.com/questions/999789

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档