How hide ssh "Connection to IP.Address closed" message on Linux

When I log out from ssh I see, “Connection to aaa.bbb.ccc.ddd closed” message. May I know where is the ‘connection to ec2-public-ip closed’ message coming from? How can I remove and hide ssh “Connection to IP.Address” message on Linux client?

You can enable quiet mode. Once enabled it causes most warning and diagnostic messages to be suppressed when using ssh command.

Hiding ssh “Connection to IP.Address” message on Linux

ssh -q user@ec2-ip
1 Like

Edit the ~/.ssh/config and append the following for your Host

LogLevel QUIET

Set log level to QUITE for all ssh sessions

Host *
   IdentitiesOnly yes
   ControlPath ~/.ssh/controlmasters/%r@%h:%p
   ControlMaster auto
   LogLevel QUIET

Removing ssh to a.b.c.d closed message for host named foo

Host foo
   LogLevel QUIET
1 Like

FYI, this will hide lots of useful and security related info too. For example, MITM message:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
SHA256:dO2xwlmwxxxxxxxxxxxxxxxxxxxxxxxxxxxxxmikA.
Please contact your system administrator.
Add correct host key in /home/vivek/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/vivek/.ssh/known_hosts:238
  remove with:
  ssh-keygen -f "/home/vivek/.ssh/known_hosts" -R "192.168.2.183"
ECDSA host key for 192.168.2.183 has changed and you have requested strict checking.
Host key verification failed.

To see such message pass the -v option to ssh:

ssh -v user@host-example-com
1 Like

thanks for all hints and answers. it eliminated my issues.


Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki