diff --git a/changelog.md b/changelog.md index faaa32a4..da38a44e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,11 @@ +TBD +============== + +Bug Fixes +-------- +* 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 7258712c..0aff2c52 100755 --- a/mycli/main.py +++ b/mycli/main.py @@ -1639,12 +1639,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