0

I have a Debian/Linux virtual machine in VirtualBox.

# uname -a
Linux debian 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux

# vi /etc/motd

##########################
Hi, welcome to the server!
##########################


~                                                                                                                                                            
~                                                                               
~                                                                               
~                                                                               
~                                                                               
"/etc/motd" 6 lines, 84 characters written
:wq!

When I exit terminal and login as root, the message in /etc/motd doesn't appear.

root@debian:~# 

How can I make the message appear?

Richard
  • 1
  • 3
  • How do you "_login as root_"? On the text console, using a GUI, via `ssh`, or some other way? – roaima Mar 02 '21 at 09:09
  • Using a GUI. Mate GUI. – Richard Mar 02 '21 at 11:11
  • I'm not aware of any GUI that displays `/etc/motd` at login or indeed at any other point – roaima Mar 02 '21 at 11:32
  • May be you are correct. For me I need a simple banner to display the message of the day, date, machine name and big banner when I open the terminal. May be I need a cat /etc/motd in /etc/profile. but I think that this is not the correct way. Do you think that disabling the GUI makes that my /etc/motd works? – Richard Mar 02 '21 at 11:44

2 Answers2

0

Modern Debian (and many other distro) use pam_motd run out of their PAM stack. See this debian wiki article for more details.

It’s possible that you have a customized PAM environment, or your root user has a ~/.hushlogin.

jsbillings
  • 24,006
  • 6
  • 56
  • 58
  • Thanks for your answer but I don't understand what is PAM and hushlogin. The referenced article is difficult to understand for me. – Richard Mar 02 '21 at 01:51
  • PAM is the Pluggable Authentication Mechanism. And is configured in /etc/pam.d/, each file for a specific service. So, if you are logging in at the text console, look in /etc/pam.d/login, which is used by the “login” process. OpenSSH uses /etc/pam.d/sshd and so on. Typically they include a generic config in the same directory. – jsbillings Mar 02 '21 at 01:53
  • I think that I have PAM configuration. But I need a step by step solution is possible. I use a Mate GUI to login for the first time and then I open the terminal session using the menu. – Richard Mar 02 '21 at 11:17
  • Sorry, I don't have step by step instructions. I suggest perusing the man pages for pam.conf to better understand the syntax. – jsbillings Mar 03 '21 at 14:27
0

You can define the banner in ssh_config (or sshd_config - it depends on the OS). Usually it is located in /etc/issue and everything you put into this issue file will be displayed when you will login through ssh.

Sysadmin
  • 286
  • 1
  • 5
  • I found /etc/ssh_config and /etc/ssh/config file. I add the banner on both files and nothing happens. – Richard Mar 02 '21 at 11:15
  • In debian it should be /etc/ssh/sshd_config Add this: Banner /etc/issue Edit /etc/issue Provide what you need, save, exit. Restart sshd service by command: systemctl restart sshd Log out from ssh session and login. Yu should see welcome message. – Sysadmin Mar 04 '21 at 18:18
  • I create the banner in /etc/issue. I get the error, “Failed to restart sshd.service not found. – Richard Mar 06 '21 at 13:17
  • systemctl status sshd should display the status of the service It is strange. Looks like you do not have sshd installed? – Sysadmin Mar 06 '21 at 16:40
  • systemctl status sshd. Unit sshd.service could not be found. How can I install sshd service? – Richard Mar 07 '21 at 17:35
  • I found on internet how to install ssh service. Let me try again your recommendation so know if it works this time. – Richard Mar 07 '21 at 17:57
  • As root, I type the command su - ricardo, and the Welcome Baner typed in /etc/issue appear perfectly. But I closed the terminal window and login again as root and as ricardo and nothing happen. I type the command # systemctl status sshd and I get this: – Richard Mar 07 '21 at 18:10
  • ● ssh.service - OpenBSD Secure Shell server Loaded: loaded (/lib/systemd/system/ssh.service; enabled; vendor preset: enab Active: active (running) since Sun 2021-03-07 13:51:27 AST; 12min ago Docs: man:sshd(8) man:sshd_config(5) Process: 31987 ExecStartPre=/usr/sbin/sshd -t (code=exited, status=0/SUCCESS) Main PID: 31988 (sshd) Tasks: 1 (limit: 2347) Memory: 1.1M CGroup: /system.slice/ssh.service └─31988 /usr/sbin/sshd -D – Richard Mar 07 '21 at 18:10
  • So the service is active but the banner in /etc/issue display only one time. :( – Richard Mar 07 '21 at 18:12
  • https://unix.stackexchange.com/questions/246436/how-to-set-a-dynamic-message-of-the-day-motd-in-debian-jessie-8-2-for-ssh – Sysadmin Mar 10 '21 at 10:32