90

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.

Stuggi
  • 3,366
  • 4
  • 17
  • 34
  • 2
    http://askubuntu.com/questions/100052/modify-the-ssh-welcome-message-to-include-system-ip-address –  Jul 12 '12 at 04:40

7 Answers7

108

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.

EEAA
  • 108,414
  • 18
  • 172
  • 242
Dane Balia
  • 1,212
  • 1
  • 9
  • 3
65

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.

Rody Oldenhuis
  • 602
  • 4
  • 13
34

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

Kelly
  • 443
  • 4
  • 7
12

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.

Stuart
  • 237
  • 2
  • 2
  • 6
    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 05 '13 at 08:25
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.

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.

David A.
  • 41
  • 2
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'
  • 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 '21 at 20:50