0

I would like to disable the PrintLastLog option for only one run of the ssh command.

I tried to pass it using the -o option:

 ssh -q -o PrintLastLog=no localhost

but I get:

command-line: line 0: Bad configuration option: printlastlog

I also don't see the PrintLastLog option in the SSH_CONFIG(5) man file. Are there options that are special and cannot be passed as command line flags?

The reason for the question is that I need to ssh to several servers from a script, and I don't want the MOTD/login message clogging up the log output from the script.

1

You don't see it there, because it's an option for the sshd daemon, not the client. You can't change server options from the client side.

However, if what you want is to do ssh in a script without doing output, you can simply redirect the output to /dev/null. Example:

for i in `< /file/with/hostnames`; do ssh $i hostname > /dev/null; done

When you use SSH to just issue a command, the only output you will get is from that command - you won't get the MOTD or the banner. And since you're redirecting that output to /dev/null, you're getting nothing.

  • Indeed! Good point! :) – Gabriel Petrovay Oct 6 '14 at 10:53
  • is there a way to tell the daemon from the client that the welcome message is not wanted? – Gabriel Petrovay Oct 6 '14 at 10:54
  • I think you're having an XY problem (meta.stackexchange.com/a/233676/214153). What is your reason for wanting to suppress this message? – Jenny D Oct 6 '14 at 11:02
  • I have a script that adds several hosts to the known_hosts before it will start to run in order to avoid the interactive mode asking the user permission to add a certain server fingerprint key. This script causes a lot of "garbage" in the terminal because of the servers that print welcome messages/last log. – Gabriel Petrovay Oct 6 '14 at 11:26
  • @GabrielPetrovay Definitely an XY problem, and now you have the answer! (And I edited your post to clarify this, hope you're OK with the edit.) – Jenny D Oct 6 '14 at 12:24

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.