没有命令/获取 shell 就无法通过 ssh 隧道

nmi*_*nic 13 ssh openssh ssh-tunneling

我想使用 ssh 隧道选项。为此,我使用命令:

ssh -L 1234:localhost:5678 host
Run Code Online (Sandbox Code Playgroud)

但是,这将我登录到远程主机上的 shell。接下来我尝试-f如下:

 ssh -f -L 8999:localhost:6006 host
Run Code Online (Sandbox Code Playgroud)

但我得到错误 Cannot fork into background without a command to execute.

我怎样才能只获得 ssh 隧道功能并在后台运行它而不会造成不必要的混乱。我的 ssh 版本是OpenSSH_7.2p2, OpenSSL 1.0.2h 3 May 2016

Zac*_*ady 17

使用 -N 选项

 -N      Do not execute a remote command.  This is useful for just for-
         warding ports (protocol version 2 only).
Run Code Online (Sandbox Code Playgroud)

例子

ssh -fN -L 8999:localhost:6006 host
Run Code Online (Sandbox Code Playgroud)


归档时间:

查看次数:

12494 次

最近记录:

9 年,5 月 前