How to disable welcome message after SSH login?
I have changed /etc/issue.net
, so I have set a "personal" message after typing a username in an SSH terminal. Now I am trying to change the welcome text after successful login.
I have found a lot of posts about the /etc/motd
file, but the part "Welcome to Ubuntu blabla versionnumber and so on" + "* Documentation URL " is not there?
I just do not want to show OS info in my SSH terminal, I already know what I have installed. :) I only want to see my last login. And also not errors; errors belong in a logfile.
Which file do I have to edit?
The welcome messages are generated by the files residing in /etc/update-motd.d/
.
From man update-motd
:
Executable scripts in /etc/update-motd.d/* are executed by pam_motd(8) as the root user at each login, and this information is concatenated in /var/run/motd.
So if you don't want the outputs of those scripts upon login via ssh
just remove the execute flag on them:
sudo chmod -x /etc/update-motd.d/*
Now if you want to show something you want upon login, you have two options:
Make a script, put it in
/etc/update-motd.d/
, make it executable, also make sure it outputs on STDOUT.-
ssh
has aBanner
option. You can put the text in a file and set it in theBanner
option so that the content of the file is shown upon login viassh
. Note that this is applicable to onlyssh
.Banner /etc/foobar
From
man 5 sshd_config
:Banner The contents of the specified file are sent to the remote user before authentication is allowed. If the argument is “none” then no banner is displayed. This option is only available for protocol version 2. By default, no banner is displayed.
Another way that does not require administrative rights is to place an empty file called
.hushlogin
into your $HOME directory (using for example touch ~/.hushlogin
).
Source that provides further info including a possible downside of this approach.
You can also nuke pam_motd
altogether:
sed -i '/^[^#]*\<pam_motd.so\>/s/^/#/' /etc/pam.d/sshd
PAM calls pam_motd
depending on the settings in /etc/pam.d
, and typically the entries are:
$ grep pam_motd /etc/pam.d -R
/etc/pam.d/login:session optional pam_motd.so motd=/run/motd.dynamic noupdate
/etc/pam.d/login:session optional pam_motd.so
/etc/pam.d/sshd:session optional pam_motd.so motd=/run/motd.dynamic noupdate
/etc/pam.d/sshd:session optional pam_motd.so # [1]
Just commenting out the pam_motd
lines from these files will disable it.
There might also be file under /etc/motd
containing a welcome message which can easily be removed (the content).