0

There is custom message that comes each time I ssh or scp which I would like to hide. I still want the rest of the stderr to go to stderr output.

For example: a.sh contain one line: ssh example.com "touch /tmp/a.log ; echo ok"

myuser@host $ ./a.sh
No valid ciphers for protocol version 2 given, using defaults.
#######
# this is prod
#
#######
ok
myuser@host $

So I want to hide the first 5 lines, or if putting it into scripting grep -v -E "#|No valid ciphers for protocol". Any other error should still be output to screen/stderr.

Jeff Schaller
  • 66,199
  • 35
  • 114
  • 250
Nir
  • 1,265
  • 7
  • 23
  • 34

2 Answers2

2
( exec 7>&1; your_command 2>&1 >&7 | grep -v msg_to_suppress >&2 )

See also https://stackoverflow.com/questions/3618078/pipe-only-stderr-through-a-filter.

0

The banner message looks like it's set on the remote server. You should be able to supress it with -q:

ssh -q example.com ...

The cipher message can be suppressed by using a cipher that matches one of the set offered by the server. Start with ssh -Q cipher and then experiment with settings such as ssh -o [email protected] ...

roaima
  • 107,089
  • 14
  • 139
  • 261