A Personal MOTD
LucasAlt
Posted on June 17, 2018
Today, we are going to modify the MOTD that appears when we connect SSH to our server. Generally, it gives you some general information about your machine. You can display the server's uptime, RAM consumption, ...
Personally, I did something simple. It only displays me a logo and text.
To make a custom MOTD, there are many different ways to do it. Personally, I chose the method where we write a basic script that we execute so that it can edit the /etc/motd
file alone.
Writing the script
As said above, I wrote a small script (koff, koff,... it's internet that wrote it for me) that I saved in a file raspi-motd.sh
. If you want the same MOTD as I do, you can find the code here: https://gist.github.com/piksel/3023588
I slightly modified the script as explained in the comments below. You just have to change the line 20 echo "$logo" > /etc/motd.tail to echo "$logo" > /etc/motd
.
Then I saved the file and executed it. Being a beginner with Linux, I had a little trouble running the file. Finally, two solutions are offered to me.
Either:
Allow the script to run,
run it with bash /path/to/script.sh
command
I first chose the first option (hehey I said I didn't understand anything) and then I thought it was time to try the second one anyway. (spoiler! The second one is faster)
First solution:
chmod +x raspi-motd.sh
gives the script execution rights
raspi-motd.sh
script is executed
Second solution
bash raspi-motd.sh
simply execute the script
Unfortunately, I have a small error, because it doesn't find the bootlogs
file in /etc/init.d/
but no worries it still works. Finally, all you need to do is reconnect and the custom MOTD will appear.
Sources:
L4p1n's blog
Source code
How to run. sh file
Images:
By myself
Posted on June 17, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.