Ubuntu 14.04 上沒有 MOTD...?

Ubuntu 14.04 上沒有 MOTD...?

我最近全新安裝了 Ubuntu 14.04。當我使用 SSH 時,沒有 MOTD(是的,我在 sshd_config 中設定了適當的命令)。

我讀了很多關於設定 MOTD 的教程,但我意識到,雖然我有 /etc/update-motd.d,但沒有 /etc/motd 文件,也沒有 /var/run/motd 文件。

我該如何設定這些才能透過 SSH 取得 MOTD?

答案1

在 Ubuntu 14.04.2 LTS 的基本安裝中,只需將您想要的訊息放入:

/etc/motd

預設情況下,MOTD 將出現在其他動態 MOTD 內容的末端。例如,以下是新增了 /etc/motd 檔案的 Vagrant ubuntu/trusty64 (v20150506.0.0) 方塊的輸出:

$ vagrant ssh
Welcome to Ubuntu 14.04.2 LTS (GNU/Linux 3.13.0-52-generic x86_64)

 * Documentation:  https://help.ubuntu.com/

  System information as of Thu May 14 20:06:56 UTC 2015

  System load:  0.39              Processes:           78
  Usage of /:   2.8% of 39.34GB   Users logged in:     0
  Memory usage: 24%               IP address for eth0: 10.0.2.15
  Swap usage:   0%

  Graph this data and manage this system at:
    https://landscape.canonical.com/

  Get cloud support with Ubuntu Advantage Cloud Guest:
    http://www.ubuntu.com/business/services/cloud

0 packages can be updated.
0 updates are security updates.


#####################################
Howdy! This message is from /etc/motd
#####################################

Last login: Thu May 14 20:06:56 2015 from 10.0.2.2
vagrant@vagrant-ubuntu-trusty-64:~$

如果您使用的是預設設定的系統,這就是全部內容。


其他一些故障排除說明:

  • 使用“/etc/motd”是對早期版本的更改。 12.02 的建議是使用“/etc/motd.tail”。這在 14.04.2 中不起作用。

  • 我看到的其他建議包括更改“/etc/ssh/sshd_config”中的一些值。如果這些已更改,則以下是有效的預設值:

    UsePAM yes
    PrintMotd no
    
  • /etc/pam.d/login同樣,以下是我所看到的引用的預設值:

    session    optional   pam_motd.so  motd=/run/motd.dynamic noupdate
    session    optional   pam_motd.so
    

這就是我所看到的故障排除參考的所有內容。

答案2

嘗試新增:

 UsePAM yes

按照您的/etc/ssh/sshd_config建議漏洞並在無法在 Ubuntu 10.04 Server 中正確配置 MOTD(找不到 update-motd 指令)

啟用 UsePAM 後,PAM 將自動更新 MOTD 並在您登入時為您列印。

我對此不確定,但如果你得到 motd 兩次,你應該設定PrintMOTD為 no。

答案3

將以下行新增至/etc/pam.d/sshd

session    optional   pam_motd.so  motd=/run/motd.dynamic noupdate

答案4

就我而言,這是因為其中一個腳本/etc/update-motd.d無法運行(給出非零退出代碼)。修復它使 MOTD 再次開始出現。

exit 0如果您不確定它是哪一個,只需在該目錄中的所有腳本中附加一行即可。

我在運行 Ubuntu Disco 和 Debian Buster 的機器上註意到了這一點,但我相信它適用於 Ubuntu Trusty(甚至 Precise)。

相關內容