在SSH会话中使用SSH客户端的ControlMaster功能以及TurnOffEscape功能来避免向其他程序发送转义提示序列。
示例代码如下:
Host *
ControlMaster auto
ControlPath ~/.ssh/ssh-%r@%h:%p
RequestTTY no
EscapeChar none
Host destination
Hostname destination.example.com
ProxyCommand ssh -W %h:%p bastion.example.com
TurnOffEscape yes
以上示例代码中:
- ControlMaster auto和ControlPath ~/.ssh/ssh-%r@%h:%p启用SSH客户端的ControlMaster功能,并指定控制套接字文件的位置。
- RequestTTY no禁用了SSH会话中的终端提示而不是通过替换shell的功能来禁用转义提示序列。
- EscapeChar none将EscapeChar设为none以完全禁用转义提示序列。它与指定TurnOffEscape标志等效。
- ProxyCommand ssh -W %h:%p bastion.example.com通过指定ProxyCommand指令来建立由联机主机到稳定主机的SSH连接。
- TurnOffEscape yes指定TurnOffEscape标志使SSH客户端使用新的ssh-session-agent程序进程来启动新的ssh客户端进程并从父进程继承代理过程,从而避免了向其他程序发送转义提示序列。