62

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.

Sorry for my bad English. I would really appreciate any help!

migrated from stackoverflow.com Jul 12 '12 at 8:37

This question came from our site for professional and enthusiast programmers.

79

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.

  • 9
    Changing PrintLastLog to NO have nagative impact on security. @RodyOldenhuis give better answer. – Igor S. Nov 9 '14 at 18:56
  • 1
    His answer was completely fine. It does explain how to change the login message. – Alexander C. Solon Mar 8 '16 at 23:42
  • sudo /etc/init.d/ssh restart after editing sshd_config – Mehdiway Dec 21 '16 at 23:50
50

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, plase 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 of course, but do so knowingly.

  • See also /etc/motd.tail which may be used, depending on the system. – jezmck Jun 19 '17 at 11:58
  • On a Debian 9 /etc/motd is a regular file and /etc/motd.tail didn't work @jezmck. – Pablo Bianchi Jan 19 '18 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? – Rody Oldenhuis Jan 19 '18 at 17:49
  • @RodyOldenhuis solve what? I just sudo nano /etc/motd and it worked. – Pablo Bianchi Jan 19 '18 at 17:53
  • @PabloBianchi: ah, I misunderstood. I thought you meant changing the regular file didn't work...Nevermind :) – Rody Oldenhuis Jan 19 '18 at 17:54
21

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

8

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.

  • 4
    This does not remove the motd message, only appends the contents of /var/www/welcome.msg before that (at least on Ubuntu 12.04) – Akseli Palén Sep 5 '13 at 8:25
2

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.

1

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.

  • Issue is the banner before login, motd is the longer message after the login. – eckes Apr 30 '17 at 23:39
0

A program which helps you displaying a welcome message

  1. Start your terminal
  2. write --> vi filename.sh
  3. press i to go into the insert mode.
  4. Start coding
clear
d=$(date +%H)
if [ $d -lt 12 ]
then
  echo "Good Morning"
elif [ $d -lt 16 ]
then
   echo "Good Afternoon"
elif [ $d -lt 20 ]
then
  echo "Good Evening"
else 
  echo "Good Night"
fi
  1. press esc key after completion

  2. now press shift+q together

  3. write wq and press ENTER \YOUR FILE HAS BEEN SAVED
  4. you have moved now into the terminal
  5. write sh filename.sh
  6. Get your welcome message
  • 1
    didn't answer the question, it's mainly a vim tutorial :) – Oren S Dec 27 '17 at 15:09

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.