Traditional unix systems display /etc/motd
after the user is successfully authenticated and before the user's shell is invoked. On modern systems, this is done by the pam_motd
PAM module, which may be configured in /etc/pam.conf
or /etc/pam.d/*
to display a different file.
The ssh server itself may be configured to print /etc/motd
if the PrintMotd
option is not turned off in /etc/sshd_config
. It may also print the time of the previous login if PrintLastLog
is not turned off.
Another traditional message might tell you whether that You have new mail
or You have mail
. On systems with PAM, this is done by the pam_mail
module. Some shells might print a message about available mail.
After the user's shell is launched, the user's startup files may print additional messages. For an interactive login, if the user's login shell is a Bourne-style shell, look in /etc/profile
, ~/.profile
, plus ~/.bash_profile
and ~/.bash_login
for bash. For an interactive login to zsh, look in /etc/zprofile
, /etc/zlogin
, /etc/zshrc
, ~/.zprofile
, ~/.zlogin
and ~/.zshrc
. For an interactive login to csh, look in /etc/csh.login
and ~/.login
.
If the user's login shell is bash and this is a non-interactive login, then bash executes ~/.bashrc
(which is really odd, since ~/.bashrc
is executed for interactive shells only if the shell is not a login shell). This can be a source for trouble; I recommend including the following snippet at the top of ~/.bashrc
to bail out if the shell is not interactive:
if [[ $- != *i* ]]; then return; fi
It is probably generated by the PAM pam_mail.so
module.
Edit /etc/pam.d/login
en comment out the line that looks like:
session optional pam_mail.so standard
Alternatively, keep the line but remove standard
if it's there, and add nopen
to the end.
It may be necessary to do the same in the /etc/pam.d/sshd
file.
See man pam_mail
for more information.
Best Answer
In Bash, custom messages can be set with MAILPATH. The man page has this example:
Trying it:
Oh, uh, okay. Must have misread the man page there.
So we have to smuggle us some color escape codes into the message...
I don't know how to color things here, just imagine it screaming in bright white blue. Color choices are subject to taste and local terminal color scheme settings.
Also check that MAILPATH was not already in use and MAIL actually has the correct path to use for MAILPATH.