Skip to content

Commit

Permalink
ENH: clean up ssh connection log messages and force only password tries
Browse files Browse the repository at this point in the history
  • Loading branch information
ZLLentz committed Mar 20, 2024
1 parent 16dfa21 commit c8c4af2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
3 changes: 3 additions & 0 deletions pmpsdb_client/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
15 changes: 14 additions & 1 deletion pmpsdb_client/ssh_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,22 @@
from typing import Iterator, TypeVar

from fabric import Connection
from fabric.config import Config
from paramiko.config import SSHConfig

logger = logging.getLogger(__name__)

DEFAULT_PW = (
("ecs-user", "1"),
)
DIRECTORY = "/home/{user}/pmpsdb"
SSH_CONFIG = """
Host *
ForwardAgent no
ForwardX11 no
ForwardX11Trusted no
PreferredAuthentications=password
"""

T = TypeVar("T")

Expand All @@ -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()
Expand Down

0 comments on commit c8c4af2

Please sign in to comment.