在 OpenSSH 中,详细模式 ( ssh -v ...
) 会在退出时显示一些有用的统计信息(例如Transferred: sent 3532, received 3076 bytes, in 5.5 seconds
)。但是,详细模式也会打印很多debug1: ...
我不关心的行。例如:
$ ssh -v -N -D localhost:12345 [email protected]
OpenSSH_8.2p1 Ubuntu-4ubuntu0.2, OpenSSL 1.1.1f 31 Mar 2020
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 5: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
--- snip ---
debug1: channel 0: free: port listener, nchannels 4
debug1: channel 1: free: port listener, nchannels 3
debug1: channel 2: free: port listener, nchannels 2
debug1: channel 3: free: port listener, nchannels 1
Transferred: sent 3532, received 3076 bytes, in 5.5 seconds
Bytes per second: sent 638.4, received 556.0
debug1: Exit status 0
如何删除所有debug1: ...
行以仅显示数据使用统计信息?我只想看到Transferred: ...
和Bytes per second: ...
线。我试过ssh -v ... 2>&1 | sed '/debug1/d'
了,但这不起作用,因为Ctrlc会产生一个 SIGINT 发送到前台进程组中的所有进程。sed
在使用统计信息发送到其标准输入之前终止,因此从不打印使用统计信息。
我使用/bin/sh
(不是 bash)作为我的外壳。
“已传输...”消息以“详细”日志级别打印。您可以使用“-o LogLevel”选项将 ssh 设置为“详细”级别:
.ssh/config
如果您希望它自动发生,您可以在文件中设置它: