是否可以按用户禁用SSH上次登录和MOTD?


8

我知道您可以通过在PrintLastLog noPrintMotd no中启动SSH会话时禁用上次登录消息和当天消息/etc/ssh/sshd_config

但是,我无权/etc/ssh/sshd_config在正在访问的系统中进行修改。有没有一种方法来设置PrintLastLog no,并PrintMotd no仅用于我的本地用户?

Answers:


10

是的,可以,将Match User指令添加到您的sshd_config文件中,如下所示:

Match User root 
    PrintlastLog no
    PrintMotd no

Match指令还可以追溯GroupAddress匹配GEOS / Unix组和IP地址。

更新:

作为每个用户的基础,而没有访问sshd_config的权限,您只需创建一个空文件,即可$HOME/.hushlogin防止bash在交互模式下输出这些警报。这在使用login(1)telnet和屏幕会话的其他系统下也适用。

更新2:

Banner在每个会话的基础上抑制sshd 的输出,请使用ssh -q <host>或包含LogLevel quiet在您的〜/ .ssh / config中


OP表示他无法修改/ etc / ssh / sshd_config
MariusMatutiae,2014年

感谢@MariusMatutiae指出这一点。我已经更新了我的答案以说明这一点。
德怀特·斯宾塞

4
~/.hushlogin取消了motd和上次登录消息。:d奖励积分,如果你可以禁用所界定的旗帜Banner /etc/issue/etc/ssh/sshd_config
亚历山大-恢复莫妮卡2014年

1
谢谢@XAleXOwnZX我完全忘记了这一点。我已经更新了答案,包括横幅抑制。
德怀特·斯潘塞

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.