From c8c4af2f288e4e184c46aee878459f93210f5109 Mon Sep 17 00:00:00 2001 From: Zachary Lentz Date: Wed, 20 Mar 2024 14:04:10 -0700 Subject: [PATCH] ENH: clean up ssh connection log messages and force only password tries --- pmpsdb_client/cli/__init__.py | 3 +++ pmpsdb_client/ssh_data.py | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pmpsdb_client/cli/__init__.py b/pmpsdb_client/cli/__init__.py index f228b23..1d38b06 100644 --- a/pmpsdb_client/cli/__init__.py +++ b/pmpsdb_client/cli/__init__.py @@ -53,6 +53,9 @@ def _main(args: argparse.Namespace) -> int: level=logging.INFO, format='%(levelname)s: %(message)s', ) + # Noisy log messages from ssh transport layer + for module in ("fabric", "paramiko", "intake"): + logging.getLogger(module).setLevel(logging.WARNING) if args.export_dir: from ..export_data import set_export_dir set_export_dir(args.export_dir) diff --git a/pmpsdb_client/ssh_data.py b/pmpsdb_client/ssh_data.py index bd4f6aa..ef0c1e2 100644 --- a/pmpsdb_client/ssh_data.py +++ b/pmpsdb_client/ssh_data.py @@ -14,6 +14,8 @@ from typing import Iterator, TypeVar from fabric import Connection +from fabric.config import Config +from paramiko.config import SSHConfig logger = logging.getLogger(__name__) @@ -21,6 +23,13 @@ ("ecs-user", "1"), ) DIRECTORY = "/home/{user}/pmpsdb" +SSH_CONFIG = """ +Host * + ForwardAgent no + ForwardX11 no + ForwardX11Trusted no + PreferredAuthentications=password +""" T = TypeVar("T") @@ -43,7 +52,11 @@ def ssh( with Connection( host=hostname, user=user, - connect_kwargs={"password": pw} + config=Config(ssh_config=SSHConfig.from_text(SSH_CONFIG)), + connect_kwargs={ + "password": pw, + "allow_agent": False, + }, ) as conn: try: conn.open()