ssh 欢迎消息突然消失

ssh 欢迎消息突然消失

当我通过 ssh 登录到我的 ubuntu 服务器时,我收到的唯一消息是最后一次登录

Last login: Sun Oct 30 18:26:33 2022 from xxx.xxx.xxx.xx

然而,之前我得到

Welcome to Ubuntu 22.04.1 LTS (GNU/Linux 5.15.0-1017-raspi aarch64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Sun Oct 30 18:40:05 UTC 2022

  System load:           0.03271484375
  Usage of /:            21.4% of 28.76GB
  Memory usage:          5%
  Swap usage:            0%
  Temperature:           49.7 C
  Processes:             143
  Users logged in:       1
  IPv4 address for eth0: xxx
  IPv6 address for eth0: xxx

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s
   just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge

0 updates can be applied immediately.

我仍然可以跑过去

sudo run-parts /etc/update-motd.d/

我不知道如何改变这种行为。我只是更新了系统并重新启动。也许是内核更新,因为有一个对话框询问应重新启动哪些服务。我并不真正理解这到底意味着什么,并试图选择每项服务,但按回车键是应用选择而不是选择服务。因此,我认为重新启动将自动重新启动所有服务。我发现了很多关于如何禁用它的线程,motd但没有关于如何启用它的线程。我找到了条目PrintMotd no/etc/ssh/sshd_condig更改为yes,并认为好的就是这样。然而这似乎没有效果。至少欢迎消息仍然没有显示。

我该怎么做才能再次启用该消息?

答案1

您应该检查 /etc/update-motd.d 目录中的文件是否可执行。您可以使用以下命令进行检查:

ls -l /etc/update-motd.d/

权限应该-rwxr-xr-x对所有文件。如果权限不同,你可以用以下命令进行更正:

chmod a+x /etc/update-motd.d/*

答案2

在安装了新的 Python 版本 3.10 并选择此 Python 版本作为默认 Python 后,我遇到了同样的问题。我使用以下命令行将 Python 版本从 3.8 更改为 3.10

sudo update-alternatives --config python3

然后,问题就出现了。

我认为如果您遇到了与我同样的问题,只需将 Python 版本改回旧版本就可以解决它。

您可以使用以下命令检查是否是python版本的问题:

run-parts /etc/update-motd.d/

运行上述命令后我收到以下警告:

Welcome to Ubuntu 20.04.6 LTS (GNU/Linux 5.15.0-1042-azure x86_64)

 * Documentation:  https://help.ubuntu.com  * Management:     https://landscape.canonical.com  * Support:        https://ubuntu.com/advantage

  System information as of Wed Jul 26 03:08:59 UTC 2023

Traceback (most recent call last):   File "/usr/bin/landscape-sysinfo", line 22, in <module>
    run(sys.argv[1:], reactor)   File "/usr/lib/python3/dist-packages/landscape/sysinfo/deployment.py", line 115, in run
    for plugin in config.get_plugins():   File "/usr/lib/python3/dist-packages/landscape/sysinfo/deployment.py", line 69, in get_plugins
    return [namedClass("landscape.sysinfo.%s.%s"   File "/usr/lib/python3/dist-packages/landscape/sysinfo/deployment.py", line 69, in <listcomp>
    return [namedClass("landscape.sysinfo.%s.%s"   File "/usr/lib/python3/dist-packages/twisted/python/reflect.py", line 173, in namedObject
    module = namedModule('.'.join(classSplit[:-1]))   File "/usr/lib/python3/dist-packages/twisted/python/reflect.py", line 159, in namedModule
    topLevel = __import__(name)   File "/usr/lib/python3/dist-packages/landscape/sysinfo/network.py", line 4, in <module>
    from netifaces import AF_INET, AF_INET6 ModuleNotFoundError: No module named 'netifaces' run-parts: /etc/update-motd.d//50-landscape-sysinfo exited with return code 1

 * Strictly confined Kubernetes makes edge and IoT secure. Learn how MicroK8s    just raised the bar for easy, resilient and secure K8s cluster deployment.

   https://ubuntu.com/engage/secure-kubernetes-at-the-edge

Expanded Security Maintenance for Applications is not enabled.

0 updates can be applied immediately.

2 additional security updates can be applied with ESM Apps. Learn more about enabling ESM Apps service at https://ubuntu.com/esm

希望以上信息有帮助!

相关内容