diff --git a/changelog.md b/changelog.md index 3a4a7451..84545e80 100644 --- a/changelog.md +++ b/changelog.md @@ -5,9 +5,11 @@ Features -------- * Allow history file location to be configured. + Bug Fixes -------- * Respect `--logfile` when using `--execute` or standard input at the shell CLI. +* Gracefully catch Paramiko parsing errors on `--list-ssh-config`. 1.44.2 (2026/01/13) diff --git a/mycli/main.py b/mycli/main.py index 0b240c73..a785146f 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -1644,12 +1644,17 @@ def cli( sys.exit(0) if list_ssh_config: ssh_config = read_ssh_config(ssh_config_path) - for host in ssh_config.get_hostnames(): + try: + host_entries = ssh_config.get_hostnames() + except KeyError: + click.secho('Error reading ssh config', err=True, fg="red") + sys.exit(1) + for host_entry in host_entries: if verbose: - host_config = ssh_config.lookup(host) - click.secho(f"{host} : {host_config.get('hostname')}") + host_config = ssh_config.lookup(host_entry) + click.secho(f"{host_entry} : {host_config.get('hostname')}") else: - click.secho(host) + click.secho(host_entry) sys.exit(0) # Choose which ever one has a valid value. database = dbname or database