I have had a couple of occasions where I was unable to remember the IP address for a given system but was, at the time, able to connect using the hostname. As an example, just now I wanted to set up port forwarding on my router and couldn't remember the IP for the target system.

I am wondering if it is possible to add the system's IP address to the welcome message that gets displayed on an SSH connection.

The default welcome message that I am trying to modify, in case that term is ambiguous, is"

Linux [hostname] 2.6.35-32-generic #64-Ubuntu SMP Tue Jan 3 00:47:07 UTC 2012 x86_64 GNU/Linux

Ubuntu 10.10

Welcome to Ubuntu!
    * Documentation:  https://help.ubuntu.com/

Somewhere in there I think I'd like to add the IP address of the system I just logged in to. Any suggestions? Other than trading in my brain for a newer model with more RAM?

3 Answers 3


The message you refer to is the "motd", or "Message of the Day". It's contained in /etc/motd.

This is generated by update-motd, documentation for which is here: https://wiki.ubuntu.com/UpdateMotd#Design

See this related question: How do I edit the ssh motd?

To directly answer your question, you could add a file called /etc/update-motd.d/50-ip-address with this content:

ifconfig |grep "inet addr"

This will very simplistically add all the configured internet addresses on your system to the motd file.

The motd is updated "at each login" (as per man update-motd). You can play with the number as the first part of the script's name to decide the order in which the IP address will appear.

As the files in /etc/update-motd.d are simply shell scripts, you can write something as simple or as complicated as you want.

  • It won't let me vote you up yet, but your answer looks like it should do what I was hoping. I'll try it out tomorrow. Cheers!
    – miststlkr
    Jan 31, 2012 at 6:05
  • 1
    Tested and confirmed. Brilliant! That gave far more info than I need but, as you said, it is a bash script so I'll have plenty to tinker with now to get it exactly where I want it. That is, after all, half of the fun of running linux!
    – miststlkr
    Feb 1, 2012 at 0:47
  • 2
    To test how it would look like without logging in again, run sudo run-parts /etc/update-motd.d/. Although to see the changes in the next login, it has to be around 10 minutes or so after your last edit. Or try logging in a couple of times until you see it.
    – ADTC
    Mar 25, 2016 at 10:57
  • There's no such file in 18.04 bionic
    – Jubei
    Feb 16, 2019 at 16:06

This may be more than you want/need, but the landscape-common package automatically adds system information, including IP addresses to the MOTD.

Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-28-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

  System information as of Tue Jul 12 10:21:51 MDT 2016

  System load:  0.09                Users logged in:        1
  Usage of /:   12.3% of 225.17GB   IP address for enp7s0:  192.168.X.XXX
  Memory usage: 45%                 IP address for wlp9s1:  192.168.X.XXX
  Swap usage:   0%                  IP address for docker0:
  Processes:    397

  Graph this data and manage this system at:

0 packages can be updated.
0 updates are security updates.

Last login: Tue Jul 12 10:03:16 2016 from 192.168.X.XXX

Specifically, it adds a symlink to /usr/share/landscape/landscape-sysinfo.wrapper in the /etc/update-motd.d/ directory.

  • Many thanks for this answer. I looking for this info for ages. Jul 22, 2017 at 20:34
  • 1
    How can I disable update-motd completely? Jan 26, 2019 at 6:54

If you wanna set a custom message, create a file in the update-motd.d folder & chmod it as shown below

sudo vi /etc/update-motd.d/01-custom

Add your custom message along with the ipconfig command to this

ifconfig |grep "inet addr"

Or in modern Linux systems ipconfig is deprecated so use the below:

ip a | grep "inet" 

And then:

sudo chmod +x /etc/update-motd.d/01-custom

Log out and log in to see your changed MOTD message.

  • apologies didnt finish completing the answer, posted by mistake Aug 1, 2020 at 18:25

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .