Skip to content

Commit 76f4d19

Browse files
authored
Merge pull request #1444 from dbcli/RW/graceful-failure-list-ssh-config
Graceful failure for `--list-ssh-config`
2 parents ea28ce9 + ec568eb commit 76f4d19

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

changelog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ Features
55
--------
66
* Allow history file location to be configured.
77

8+
89
Bug Fixes
910
--------
1011
* Respect `--logfile` when using `--execute` or standard input at the shell CLI.
12+
* Gracefully catch Paramiko parsing errors on `--list-ssh-config`.
1113

1214

1315
1.44.2 (2026/01/13)

mycli/main.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,12 +1644,17 @@ def cli(
16441644
sys.exit(0)
16451645
if list_ssh_config:
16461646
ssh_config = read_ssh_config(ssh_config_path)
1647-
for host in ssh_config.get_hostnames():
1647+
try:
1648+
host_entries = ssh_config.get_hostnames()
1649+
except KeyError:
1650+
click.secho('Error reading ssh config', err=True, fg="red")
1651+
sys.exit(1)
1652+
for host_entry in host_entries:
16481653
if verbose:
1649-
host_config = ssh_config.lookup(host)
1650-
click.secho(f"{host} : {host_config.get('hostname')}")
1654+
host_config = ssh_config.lookup(host_entry)
1655+
click.secho(f"{host_entry} : {host_config.get('hostname')}")
16511656
else:
1652-
click.secho(host)
1657+
click.secho(host_entry)
16531658
sys.exit(0)
16541659
# Choose which ever one has a valid value.
16551660
database = dbname or database

0 commit comments

Comments
 (0)