99

I have a VPS for my website hosting. It is running a Ubuntu server. Every time I logged in my server by ssh, it displays a lengthy welcome message in my terminal.

Linux node61.buyvm.net 2.6.18-pony6-3 #1 SMP Tue Mar 13 07:31:44 PDT 2012 x86_64

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 Jul 11 12:08:19 2012 from 113.72.193.52 Linux node61.buyvm.net 2.6.18-pony6-3 #1 SMP Tue Mar 13 07:31:44 PDT 2012 x86_64

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. entered into CT 17323 -bash-4.2#

After doing some researches about this(yes i was just googling around), I realized that my server should have a .bashrc and .bash_profile (or .profile) controlling this. I use vim to open my .bashrc and .profile and I couldn't seem to find any line of codes that would display message in my terminal. Therefore I am wondering if there is like another file for this?

I want to comment out those welcome message because my SFTP is not working with an error (Received message too long 761422195). I am pretty sure that this error is caused by my server's welcome message.

1

8 Answers 8

122

You need to edit two files:

  1. /etc/motd (Message of the Day)
  2. /etc/ssh/sshd_config: Change the setting PrintLastLog to "no", this will disable the "Last login" message.

And then restart your sshd.

4
  • 14
    Changing PrintLastLog to NO have nagative impact on security. @RodyOldenhuis give better answer.
    – Igor S.
    Nov 9, 2014 at 18:56
  • 1
    His answer was completely fine. It does explain how to change the login message. Mar 8, 2016 at 23:42
  • 1
    sudo /etc/init.d/ssh restart after editing sshd_config
    – Mehdiway
    Dec 21, 2016 at 23:50
  • Note: the ssh motd is not the same as the versionAddendum which can be changed in sshd_config
    – Ray Foss
    Oct 10, 2020 at 3:03
71

You need to change the contents of /etc/motd. Unfortunately, by default, /etc/motd is a link to /var/run/motd which gets reset every time you login. To make permanent changes, please do the following:

sudo rm /etc/motd
sudo nano /etc/motd

or whatever editor you prefer. Then enter the message you want shown if any, and save the file.

Removing the "last seen" message (e.g., setting PrintLastLog to no in /etc/ssh/sshd_config) is not recommended -- time of last login is valuable security information. It allows for a way to check if someone you did not expect has logged into the system recently. Anyway, it's possible, but do so knowingly.

5
  • See also /etc/motd.tail which may be used, depending on the system.
    – jezmck
    Jun 19, 2017 at 11:58
  • On a Debian 9 /etc/motd is a regular file and /etc/motd.tail didn't work @jezmck.
    – Pablo A
    Jan 19, 2018 at 17:40
  • @PabloBianchi hmm...I don't have a similar system to test this. Can you let me know if/when you managed to solve it? Jan 19, 2018 at 17:49
  • @RodyOldenhuis solve what? I just sudo nano /etc/motd and it worked.
    – Pablo A
    Jan 19, 2018 at 17:53
  • 1
    @PabloBianchi: ah, I misunderstood. I thought you meant changing the regular file didn't work...Nevermind :) Jan 19, 2018 at 17:54
38

On a per-user basis, you can run touch ~/.hushlogin to disable the messages.

15

Create a new file and edit the welcome message. Edit /etc/ssh/sshd_config. In that there will be a line called

#Banner /some/path

Edit that path with the newly created welcome message path.

Like,

Banner /var/www/welcome.msg

Restart ssh. Now it 'll work.

2
  • 8
    This does not remove the motd message, only appends the contents of /var/www/welcome.msg before that (at least on Ubuntu 12.04) Sep 5, 2013 at 8:25
  • This is almost exactly what I am looking for, but I don't want to see it unless you log in. The banner shows up to everyone hitting your server whether they get in or not.
    – BrianBlaze
    Sep 25, 2023 at 21:49
6

In most Linux distributions, including Ubuntu, the /etc/update-motd.d/ folder contains scripts that are used to generate the Message of the Day (MoTD) displayed when a user logs into the system via SSH. These scripts can be used to display relevant or interesting information to users upon accessing the system.

Here are some of the default files you might find in the /etc/update-motd.d/ folder on an Ubuntu system:

00-header: This file displays the header of the Message of the Day. It can contain information such as the system's name, OS version, and other identifying details.

10-help-text: This file provides a brief introduction on how to get help within the system.

50-motd-news: This file might display relevant system news or announcements.

80-esm: This file shows information about Extended Security Maintenance (ESM) if this service is active on the system.

91-release-upgrade: This file could show information about version upgrades and commands for upgrading the system.

1
  • 1
    By making a bash file that I called /etc/update-motd.d/99-mywelcomemessage have my welcome message just above the last login info line.
    – BrianBlaze
    Sep 25, 2023 at 22:50
5

Could be modifying the /etc/issue file, try this:

Current date: \d Current time: \t System name: \s Architecture: \m OS build info: \v Hostname: \n Kernel: \r Number of logged-in users: \u.

1
  • Issue is the banner before login, motd is the longer message after the login.
    – eckes
    Apr 30, 2017 at 23:39
3

Create the file /etc/motd.tail and write there everything you need. The file /etc/motd will be generated upon every system boot based on the contents of /etc/motd.tail.

0

Another way is to use neofetch, like neofetch example

to accomplish that you need to

  • call sudo apt-get install neofetch
  • call sudo bash -c $'echo "neofetch" >> /etc/profile.d/mymotd.sh && chmod +x /etc/profile.d/mymotd.sh'
1
  • We've found that link-only answers rot over time. Please add at least a summary of what the target page shows, so this answer can stand alone. Otherwise, this answer will get (eventually) deleted when the linked page disappears.
    – sysadmin1138
    Mar 16, 2021 at 20:50

You must log in to answer this question.