4

I am currently using Raspbian Stretch Lite and would like to know how, if possible, I could make custom login messages.

e.g

Currently, I get this:

Linux RPi 4.9.41-v7+ #1023 SMP Tue Aug 8 16:00:15 BST 2017 armv7l

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: Wed Oct 11 18:54:03 2017 from 172.16.0.79

But I would like to get something like this:

Welcome back.
Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Something here.
More...
I think you get the idea...
6

This is, as mentioned, the contents of the /etc/motd file. The actual file shown (/run/motd.dynamic) is constructed using the scripts in /etc/update-motd.d and the file /etc/motd.

So for static content you can modify /etc/motd but if you want to generate dynamic content then you should add scripts to the /etc/update-motd.d directory.

  • This is the right way to add your own dynamic messages, or scripts. – not2qubit Feb 7 '18 at 7:17
2

That is the "Message of the Day" or "motd" you can find it in /etc/motd

sudo nano /etc/motd
1

You can also write your own scripts that get launched by rc.local (which is the very last thing that happens in the boot sequence). For example you can clear the screen and then echo out a custom message.

Check out this wonderful page

1

I wrote a blog post for this site's inactive blog that covers exactly how to do this as part of a wider series of posts on SSH.

To change the message that is displayed after a successful login, edit the /etc/motd file.

sudo nano /etc/motd

Note: This file is static and will not evaluate any included code.

Make your changes to this file - I usually just remove this text.

Save your changes:

Ctrl-o and Enter

and exit the editor:

Ctrl-x

Test your changes by exiting your SSH session:

Exit

And reconnect. You should see your custom message after logging in.

Note: by default you will see the last login time and machine used to connect. For security reasons I suggest leaving this. It can alert you that a security breach may have occurred.

The above-mentioned post also explains how to change the message displayed before login.

1

I spent a while running down a rabbit hole on this and I wanted to add something. The motd solution provided here works for the message displayed after the login is authenticated (after entering the password). And that is what I was looking for. So thanks.

But in the process I also found this tid-bit that someone might find useful since it is related...

If you want a message displayed just 'before' prompted for the password, you can also edit the /etc/ssh/sshd_config file. Locate the line or add a line like this:

Banner /path/filename

Where the filename is whatever message (like the motd file) you want displayed.

You have to restart ssh of course...

sudo /etc/init.d/ssh restart

This might come in useful if you wanted to provide instructions to the remote user prior to giving a password - or perhaps a warning to intruders etc..

  • cheers

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.