I can't find how to add a message after the "last login..." line on my Ubuntu 14.04. I can edit everything before using the files in /etc/update-motd.d/ and I can show/hide the last login message using the config file /etc/ssh/sshd_config.

But how can I add something after that?. Or, alternatively, how can I edit the last login message?

  • Why do you need the message to appear after the last login line? What are you trying to achieve? There might be a better way.
    – terdon
    Jul 9, 2014 at 13:16

1 Answer 1


One way would be to run a command in the bashrc for SSH connections:

In /etc/bash.bashrc (for system-wide) or ~/.bashrc (for your user only), append these lines:

if [[ -n $SSH_TTY ]]
    # Do stuff to get the output.
    echo "Hi, SSH user $USER!"

I don't know how to edit the last login message, but you can disable it and simulate it by using the last command, and the filter and modify the output according to your need.

  • Using your solution with the ~/.bashrc is working fine. But not with the /etc/bash.bashrc.
    – tweetysat
    Aug 4, 2014 at 8:01
  • @tweetysat i use the same test to set the prompt, and it usually works fine in the system-wide way.
    – muru
    Aug 4, 2014 at 11:09
  • I made again some tries with /etc/bash.bashrc. Suppose I added a line to display time. I'm connecting via ssh with user toto. Nothing displays. I'm doing su toto. The time is displayed.
    – tweetysat
    Aug 11, 2014 at 13:26
  • I think I have to put it in /etc/profile for system-wide and in ~/.bashrc for user only
    – tweetysat
    Aug 11, 2014 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.