How to remove 'connection to xx.xxx.xx.xxx closed' message?
if you add -o LogLevel=QUIET
to the SSH command line, that message should disappear:
ssh -o LogLevel=QUIET -t $SSH "
some
commands
"
You can also add it to the ~/.ssh/config
file as a line saying LogLevel QUIET
That is coming from SSH. You see it because you gave the -t
switch, which forces SSH to allocate a pseudo-terminal for the connection. Traditionally, SSH displays that message to make it clear that you are no longer interacting with the shell on the remote host, which is normally only a question when SSH has a pseudo-terminal allocated.
As Fran mentioned, this is coming about because of the -t switch. You can hide the message by appending:
2> /dev/null
Your code would look like this:
#!/bin/bash ssh -t $SSH " some commands " 2> /dev/null
This redirects STDERR to /dev/null. Keep in mind all error messages that may be raised will also be redirected to /dev/null and so will be hidden from view.