Skip to content

Commit

Permalink
added ssh connection logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pasenor committed Feb 14, 2021
1 parent deff68f commit d9c604d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
11 changes: 11 additions & 0 deletions mycli/packages/ssh_client/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""A very thin wrapper around paramiko, mostly to keep all SSH-related
functionality in one place."""
from io import open
import logging

_logger = logging.getLogger(__name__)

try:
import paramiko
Expand All @@ -23,6 +26,14 @@ def create_ssh_client(ssh_host, ssh_port, ssh_user, ssh_password=None, ssh_key_f
client = paramiko.SSHClient()
client.load_system_host_keys()
client.set_missing_host_key_policy(paramiko.WarningPolicy())
_logger.debug(
f'Connecting to ssh server with \n'
' host = {ssh_host}\n'
' port = {ssh_port}\n'
' user = {ssh_user}\n'
' password = {ssh_password}\n'
' key_filename = {ssh_key_filename}\n'
)
client.connect(
ssh_host, ssh_port, ssh_user, password=ssh_password, key_filename=ssh_key_filename
)
Expand Down
7 changes: 4 additions & 3 deletions mycli/sqlexecute.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ def connect(self, database=None, user=None, password=None, host=None,
'\tsocket: %r'
'\tcharset: %r'
'\tlocal_infile: %r'
'\tssl: %r',
'\tinit_command: %r',
'\tssl: %r'
'\tinit_command: %r'
'\tusing ssh: %r',
db, user, host, port, socket, charset, local_infile, ssl,
init_command
init_command, bool(ssh_client)
)
conv = conversions.copy()
conv.update({
Expand Down

0 comments on commit d9c604d

Please sign in to comment.