我有以下网络拓扑:
workstation <-> network_device <-> authentication_server
Run Code Online (Sandbox Code Playgroud)
network_device
当我通过workstation
SSH登录时,然后network_device
使用 TACACS+ 检查authentication_server
我是否有登录权限、我的访问权限是什么network_device
等。当我执行ssh -o LogLevel=quiet network_device
inworkstation
时,我看不到网络设备横幅,但我看到了看到如下提示:
$ ssh -o LogLevel=quiet network_device
TACACS authentication!
Password:
$
Run Code Online (Sandbox Code Playgroud)
该TACACS authentication!
字符串由 设定authentication_server
。当我执行时ssh -vvv -o LogLevel=quiet network_device
,我发现这个横幅和密码提示似乎有不同的消息 ID。横幅:
debug3: receive packet: type 53
debug3: input_userauth_banner
*************************************************
* Access limited to Authorized Users only *
*************************************************
Run Code Online (Sandbox Code Playgroud)
密码提示:
debug3: receive packet: type 60
debug2: input_userauth_info_req
debug2: input_userauth_info_req: num_prompts 1
TACACS authentication!
Password:
Run Code Online (Sandbox Code Playgroud)
OpenSSH 客户端LogLevel
选项的工作方式是否只是根据LogLevel
值过滤某些消息 ID?手册页没有解释,到底如何LogLevel
决定显示什么:
LogLevel
Gives the verbosity level that is used when logging messages from ssh(1). The possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3. The default is
INFO. DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher levels of verbose output.
Run Code Online (Sandbox Code Playgroud)
您想了解的大部分内容都在log.c
OpenSSH 源代码中。有一个名为 的枚举变量log_level
。(枚举意味着它的作用就像引擎盖下的数字,但每个级别都与一个易于理解的名称相关联。)此log_level
变量是全局设置的,并充当隐藏您不感兴趣的日志的掩码。
然后,每当记录某些内容时,该消息也会与重要性级别相关联,并且消息+重要性被赋予一个名为 的函数do_log
。
在该do_log
函数中,我们看到以下检查:
if (!force && level > log_level)
return;
Run Code Online (Sandbox Code Playgroud)
这意味着如果该消息不如配置的日志级别重要,则该消息将从日志输出中删除。
该do_log
函数执行额外的处理,例如使用消息的重要性级别来决定是否在输出中添加前缀fatal
或任何适当的前缀。
归档时间: |
|
查看次数: |
26130 次 |
最近记录: |