18

When I rsync or scp from a particular server I get a rather long message telling me the rules of the server. However when I setup regular pulls, I'd like to be able to suppress those messages in my logs. Looking through the man page suggest that -q should work, but that only quiets messages from scp itself. How can I do this?

5 Answers 5

25

In case you don't want to mess with your local ~/.ssh/config file and the --no-motd option is not working for you either, I had success setting the RSYNC_RSH env variable.

RSYNC_RSH="ssh -q" rsync

You may also try to use the rsync option -e

rsync -e 'ssh -q'
1
  • 1
    That worked for me when --no-motd failed.
    – RonJohn
    Commented Sep 26, 2018 at 9:24
6

For rsync, it has a --no-motd you can use to suppress the motd for your script and only see the output of what rsync is transferring. It looks like it was added in rsync 3.x since I don't see that option in 2.x.

The man page lists a caveat about not using it when trying to get a listing of modules you can rsync:

--no-motd

This option affects the information that is output by the client at the start of a daemon transfer. This suppresses the message-of-the-day (MOTD) text, but it also affects the list of modules that the daemon sends in response to the "rsync host::" request (due to a limitation in the rsync protocol), so omit this option if you want to request the list of modules from the daemon.

For scp, trying touching the file ~/.hushlogin. When I scp files, I don't see the motd though but your set up might be different. The man page for login has more info:

If the file .hushlogin exists, then a "quiet" login is performed (this disables the checking of mail and the printing of the last login time and message of the day). Otherwise, if /var/log/lastlog exists, the last login time is printed (and the current login is recorded).

1
  • 9
    rsync --no-motd does not work for me. The SSH MOTD is still being shown.
    – Alicia
    Commented Sep 10, 2013 at 16:55
6

If your version of rsync doesn't support the --no-motd option, puting LogLevel quiet in ~/.ssh/config will do the trick.

1
  • The LogLevel quiet option worked for me. Note: I did have to create the file (~/.ssh/config), but I put in the one line, and voila! no more /etc/issue.net showing up!
    – user80656
    Commented Aug 12, 2014 at 20:42
1

You can probably suppress the motd by redirecting STDERR to /dev/null, but that way you will miss all other error messages too.

scp src dst 2> /dev/null
2
  • This is not an option, all output is being directed to a log file that needs review later - errors are important!
    – Hooked
    Commented Dec 27, 2012 at 22:21
  • Well stop being too biased. I think his solution is better than someone who suggested LogLevel quiet option which by the way suppressed all warnings and errors.
    – MaXi32
    Commented Aug 26, 2021 at 9:58
1

On my SuSE 11 system, I found the banner message in /etc/issue.net and then remarked out the banner line in my /etc/ssh/sshd_config file.

#banner /etc/issue.net

Then restarted the ssh daemon

service sshd restart

This suppressed the banner when using scp inside scripts and cleaned up the log files.

1
  • If the contents of issue.net must be shown, put them in a static /etc/motd or add it to whatever generates that file, and enable PrintMotd in sshd's config (default is enabled). That way it will be visible for interactive logins.
    – Walf
    Commented Feb 28, 2023 at 1:38

You must log in to answer this question.

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