Can I disable SSH last-login and MOTD on a per-user basis?
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: A Thousand Exotic Places Looping v001
--
Chapters
00:00 Can I Disable Ssh Last-Login And Motd On A Per-User Basis?
00:30 Accepted Answer Score 12
01:59 Answer 2 Score 4
02:18 Thank you
--
Full question
https://superuser.com/questions/704590/c...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#linux #ssh #permissions
#avk47
ACCEPTED ANSWER
Score 12
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
Update 3:
Match - takes one or more criteria-pattern pairs; User, Group, Host, LocalAddress, LocalPort, RDomain, and Address. Or the single token All which matches all criteria.
PrintLastLog - sshd(8) should print the date and time of the last user login
PrintMotd - Specifies whether sshd(8) should print /etc/motd when a user logs in interactively.
Non-standard SSH daemons like dropbear(8) may die with advance configurations like Match statements.
ANSWER 2
Score 4
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