在 SSH 欢迎消息中仅显示上次登录

在 SSH 欢迎消息中仅显示上次登录

当我登录到我的树莓派时,它会向我显示此消息,我喜欢它显示上次登录的事实,但信息太长(也是因为我从移动设备登录)。

Linux RaspberryPi 4.1.11+ #822 PREEMPT Fri Oct 23 16:14:56 BST 2015 armv6l

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Thu Oct 29 17:00:38 2015 from computer.local

有可能显示这个吗?

Last login: Thu Oct 29 17:00:38 2015 from computer.local

另外,显示 IP 地址而不是解析的名称?

我知道我可以看到 auth.log 但我想知道这是否可能。

答案1

此消息来自标准文件/etc/motd,管理员可以在其中放置登录人员的信息。只需清空它即可,例如:

sudo sh -c '>/etc/motd'

您可以使用以下命令获取上次登录的 IP 地址

last -i $USER | grep -v 'still logged' | head -1

从下面的评论来看:PrintMotd noin/etc/ssh/sshd_config似乎是debian中的默认值,但没有效果:ssh仍然显示/etc/motd文件。

相关内容