是否可以仅显示来自ssh的调试消息?


0

是否可以仅显示来自ssh命令的调试消息:

debug1: Entering interactive session.
debug1: Sending environment.

并过滤警告消息,如:

Pseudo-terminal will not be allocated because stdin is not a terminal.
Warning: Permanently added 'hostname' (RSA) to the list of known hosts.

有一个选项'-q'可以禁用警告消息,bug也会禁用所有调试消息。

我可以拥有一个而没有另一个吗?

Answers:


1

所有调试消息都以字符串开头debug{1,2,3},所以你可以简单地使用grep来做这个,例如像这样(请注意这些消息在stderr上):

ssh -vvv host 2>&1 | grep "^debug[123]"

但它当然会过滤掉你的密码和shell提示符以及其他重要消息。如果要将其过滤到某个文件中,它可以像这样工作:

ssh -vvv host 2>&1 | tee >(grep "^debug[123]" > file)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.