Suppress SSH login notifications

Suppress SSH login notifications

We regularly see that the so-called deploy services suffer from output that we generate when logging in via SSH (e.g. pre-login/motd). This output has the function to show the user important information, but in the case of automatic processes this is not always desirable. This behavior is often fairly easy to fix.

In all cases you need to pass the -q parameter in the SSH command (we assume you are using the OpenSSH client). This will suppress the pre-login message. To also skip the Last Login message you need to create a .hushlogin file ( touch ~/.hushlogin ) on your server.

A deploy process can log in in 2 ways, namely with a:

Login shell

In a login shell the .bash_profile is read and the MOTD is also shown. You can suppress this in 2 ways:

  • NOMOTD=true ssh -q -o SendEnv=NOMOTD @d-example.host-ed.eu -p 22622 use (when using the OpenSSH client)
  • By creating the file ~/.no-motd and in the home directory. This is the most drastic way because normal users will not see the message anymore.

Non-interactive shell

In this case the .bash_profile file is ignored and you just need to pass the -q parameter with SSH and create the .hushlogin file.