Search code examples
pythonparamiko

Suppressing Output of Paramiko SSHClient Class


When I call the connect function of the Paramiko SSHClient class, it outputs some log data about establishing the connection, which I would like to suppress.

Is there a way to do this either through Paramiko itself, or Python in general?


Solution

  • Paramiko doesn't output anything by default. You probably have a call to the logging module, setting a loglevel that's inherited when paramiko sets up it's own logging.

    If you want to get at the paramiko logger to override the settings:

    logger = paramiko.util.logging.getLogger()
    

    There's also a convenience function to log everything to a file:

    paramiko.util.log_to_file('filename.log')