Risolto da solo grazie
echo "To: " >> .loginmessage
echo "From " >> .loginmessage
echo "SSH Login" >> .loginmessage
echo "From User:" >> .loginmessage
nano /root/.bashrc
e ci aggiungo questo
cp .loginmessage .loginmessagetmp
whoami >> .loginmessagetmp
echo $SSH_CONNECTION >> .loginmessagetmp
echo " On the local server at:" >> .loginmessagetmp
date -u >> .loginmessagetmp
who >> .loginmessagetmp
sendmail < .loginmessagetmp
rm -rf .loginmessagetmp