1

In Ubuntu, I added file under /etc/update-motd.d/

#!/bin/bash

IP=$(echo $SSH_CONNECTION | cut -d ' ' -f 1)

if [ "$IP" = 172.16.20.10 ];    then 
    printf "\nHi Frank\n"
elif [ "$IP" = 172.16.20.20 ];  then 
    printf "\nHi, Eliot. Nice to see you!!\n"
else
    printf "\nWho are you?\n"
fi  

It does not working because echo $SSH_CONNECTION had not ready when motd executed.

How can I resolve it?

1
  • You may be able to change the file on each login via the sshd ForceCommand option or PAM. Commented Aug 17, 2017 at 19:05

1 Answer 1

0

You can't.... the motd is a static file... Ubuntu has an update-motd tool which periodically regenerates this file, but there is no way to do anything related to a connection using the motd.

You can probably include something equivalent in the /etc/profile... which is run after someone logs in.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .