我正在寻找一个ssh客户端配置指令,如LocalForward,它作为-L CLI参数工作,但用于-R参数
TL;DR问题的全部细节
repoServer -> myComputer -> NAT -> stagingServer
我有一个本地的git存储库服务器,它不公开在互联网上,还有一个远程的临时服务器,我必须在它上部署我的回购。
为此,我使用反向套接字进入远程stagingServer。
myComputer的当前配置:
文件:~/.ssh/config
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
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
发布于 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
Host StagingServer
Hostname staging.acme.com
User username
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_username
ForwardAgent yes
RemoteForward 8022 repository.local:22https://serverfault.com/questions/999789
复制相似问题