ssh/config文件中的ssh隧道命令在ubuntu 20.04上不起作用



我的~/.ssh/config文件中有以下配置:

Host github.myteam.tun
User johndoe
IdentityFile ~/.ssh/johndoe
ProxyCommand ssh -L 2443:github.myteam.dev:443 -f -v -N -o ControlMaster=no -o ExitOnForwardFailure=yes -o ConnectTimeout=10 -o NumberOfPasswordPrompts=3 -o TCPKeepAlive=no -o ServerAliveInterval=60 -o ServerAliveCountMax=1 cs.gate

当我键入命令时:

ssh github.myteam.tun 

它给出这样的错误:

kex_exchange_identification:连接被远程主机关闭

但是,如果我粘贴命令:

ssh -L 2443:github.myteam.dev:443 -f -v -N -o ControlMaster=no -o ExitOnForwardFailure=yes -o ConnectTimeout=10 -o NumberOfPasswordPrompts=3 -o TCPKeepAlive=no -o ServerAliveInterval=60 -o ServerAliveCountMax=1 cs.gate

它运行良好。

这似乎是因为ubuntu版本20.04。请帮我解决这个问题。提前谢谢。

如果您想通过另一个命令对ssh连接本身进行隧道传输,则会使用ProxyCommand——这不是您在这里要做的!

请尝试以下配置

Host github.myteam.tun
User johndoe
IdentityFile ~/.ssh/johndoe
Hostname cs.gate
LocalForward 2443 github.myteam.dev:443 # ssh -L
ForkAfterAuthentication yes # ssh -f
SessionType none # ssh -N
LogLevel VERBOSE # ssh -v
ControlMaster no
ExitOnForwardFailure yes
ConnectTimeout 10
NumberOfPasswordPrompts 3
TCPKeepAlive no
ServerAliveInterval 60
ServerAliveCountMax 1

最新更新