Modify the SSH welcome message to include system IP address

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:

#!/bin/bash
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.


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: 172.17.0.1
  Processes:    397

  Graph this data and manage this system at:
    https://landscape.canonical.com/

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.