I have a custom shell in /bin/
that returns an echo and exists.
I have a user that is exclusively linked to that shell only so that when someone tries to ssh into the server using that user via pubkey only, the custom shell will echo something and exit immediately (closes the ssh conenction right after the echo).
The problem is that it's working but it's showing the default Ubuntu MOTD / Banner after the authentication, while i only want to return the echo.
expected
local@sever:~$ ssh honeypot@remote-server
Welcome 1.2.3.4 | you've been logged
Connection to remote-server closed.
local@server:~$
what is happening
local@sever:~$ ssh honeypot@remote-server
Welcome to Ubuntu 16.04.x LTS (GNU/Linux x.x.x-xxx-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
Get cloud support with Ubuntu Advantage Cloud Guest:
http://www.ubuntu.com/business/services/cloud
6 packages can be updated.
0 updates are security updates.
New release '18.04.1 LTS' available.
Run 'do-release-upgrade' to upgrade to it.
*** System restart required ***
Last login: Thu Oct 2 01:08:16 2017 from 1.2.3.4
Welcome 1.2.3.4 | you've been logged
Connection to remote-server closed.
local@server:~$
Note: i don't want to disable MOTD/Banner for all other users
and I've tried the Match User honeypot Banner none
in sshd, it didn't work. Also tried the /etc/profile
thingy where I check for this user using whoami.
Edit: I found a workaround, posted as an answer but I'm still looking for an appropriate answer.
/etc/ssh/sshd_config
and put it in/etc/bashrc
. This won't display banner for all users but only for these which are using bash (and of course fro these who in.bashrc
source/etc/bashrc
)/etc/motd
, and not fromsshd
. In that case,touch ~honeypot/.hushlogin
will suppress it.