Can I disable SSH last-login and MOTD on a per-user basis?
Solution 1:
Yes you can, add the Match User
directive to your sshd_config file like so:
Match User root
PrintlastLog no
PrintMotd no
The Match
directive also works for Group
and Address
to match for GEOS/Unix group and IP Address retrospectively.
Update:
As a per user basis without access to the sshd_config then you would just create an empty file in $HOME/.hushlogin
which would prevent bash in interactive mode to output these alerts. This also works under other systems that use login(1)
such as telnet and screen sessions.
Update 2:
To surpress the Banner
output from sshd on a per session basis use ssh -q <host>
or include LogLevel quiet
in your ~/.ssh/config
Solution 2:
Not all OpenSSH implementations as those in Ubuntu allow PrintMotd or PrintlastLog in Match User section.
One may find this askubuntu question usefull with some workaround if s/he got error like:
/etc/ssh/sshd_config line 97: Directive 'PrintMotd' is not allowed within a Match block