use*_*408 25 openssh port-forwarding
OpenSSH 客户端有一个用于端口转发的命令行选项,使用方式如下:
\nssh -L localport:server:serverport user@host\nRun Code Online (Sandbox Code Playgroud)\n它将连接到hostas user,同时localport在客户端上重定向到serverporton server(可以是host或host通过网络可访问的任何内容)。
现在假设我已经通过 SSH 进行了host操作
ssh user@host\nRun Code Online (Sandbox Code Playgroud)\n在会话进行到一半时,我意识到我忘记转发端口。唉,我正在做某事,所以我不想 \xe2\x80\x99t 只是想注销并通过端口转发重新建立 SSH 连接。
\n有没有办法将端口转发添加到正在运行的 SSH 会话?
\nKam*_*ski 49
From man 1 ssh:
\n\nESCAPE CHARACTERS
\nWhen a pseudo-terminal has been requested, ssh supports a number of functions through the use of an escape character.
\nA single tilde character can be sent as
\n~~or by following the tilde by a character other than those described below. The escape character must always follow a newline to be interpreted as special. The escape character can be changed in configuration files using theEscapeCharconfiguration directive or on the command line by the-eoption.The supported escapes (assuming the default
\n~) are:[\xe2\x80\xa6]
\n\n
~C
\nOpen command line. Currently this allows the addition of port forwardings using the-L,-Rand-Doptions (see above). [\xe2\x80\xa6] Basic help is available, using the -h option.
So type Enter~C (i.e. capital c), then
-L localport:server:serverport\nRun Code Online (Sandbox Code Playgroud)\nwith desired localport, server and serverport, finally Enter.
Notes:
\nThe initial Enter will be immediately sent to the remote side and may cause some action there, so pick a good moment (e.g. when you\'re in a shell with an empty command line). Or if you are sure the last thing you have typed is Enter anyway (e.g. you have just invoked a command that is now running), you can start directly with ~ because Enter has already been noticed by your local ssh.
On internationalized keyboards the tilde could be a dead key for generating special \'tilded\' characters (like pressing ~n to generate \xc3\xb1). In that case, it could be necessary to press SPACE after ~ to generate a single tilde, i.e: ENTER~SPACEC. In the case of the Spanish/LA keyboard layouts, as there is no combined character using tilde and C, the space can be omitted and the ~C generates the desired sequence.
对于多个重定向,ssh转义的命令行仅接受单个命令。您应该再次按键盘序列以输入另一个命令或重定向。
| 归档时间: |
|
| 查看次数: |
5887 次 |
| 最近记录: |