quantumsheep / sshs

Terminal user interface for SSH
MIT License
612 stars 17 forks source link

[ISSUE] - Multiple Host Configuration Inheritance not working as expected #71

Closed saldru closed 4 months ago

saldru commented 4 months ago

Hi all,

First of all, thanks for the tool, it's really helpfull! :)

With the rewrite of the code, it seems that sshs is not parsing the ssh configuration as before and does not work like OpenSSH does.

My file structure looks like this :

.ssh
├── config
└── zones
    ├── infra1
    ├── infra2
    └── cust
        ├── cust1
        └── cust2

With a simple ssh config file that contains Include to other ssh config files located in the `zones' subdirectory. This allow me, like many people, to structure and separate ssh configuration for every different infrastructure.

My ssh zones files looks like this:

Host device01.domain.tld
        Hostname 10.0.0.1

Host device02.domain.tld
        Hostname 10.0.0.2

Host device03.domain.tld
        Hostname 10.0.0.3

Host *.domain.tld
    User bob
    ProxyJump jump01
    IdentityFile ~/path/to/private/key/cust1_id_ed25519

In version 3.4.0, this configuration was handled correctly and all the Host matching block where read by sshs and I was able to connect to device01.domain.tld using the proper user, ssh key, cipher, command and proxy jump.

Since version 4.0.0 and more specifically with 4.1.0, sshs to device01.domain.tld will not read other Host block and will only apply the configuration of the individual Host block. This mean that using sshs to connect to device01.domain.tld will not use bob as user, not use the specified IdentityFile neither the Proxy Jump configuration.

To make it works in version 4.1.0 my ssh zone file need to look like this:

Host device01.domain.tld
    Hostname 10.0.0.1
    User bob
    ProxyJump jump01
    IdentityFile ~/path/to/private/key/cust1_id_ed25519

Host device02.domain.tld
    Hostname 10.0.0.2
    User bob
    ProxyJump jump01
    IdentityFile ~/path/to/private/key/cust1_id_ed25519

Host device03.domain.tld
    Hostname 10.0.0.3
    User bob
    ProxyJump jump01
    IdentityFile ~/path/to/private/key/cust1_id_ed25519

It works, but it makes the configuration heavier and more complex to maintain.

Looks like a bug in the parser as it does not read any other Host blocks.

Thanks for your help :) Saldru

quantumsheep commented 4 months ago

Hey! Sorry to hear that, it will work well this way:

Host *.domain.tld
    User bob
    ProxyJump jump01
    IdentityFile ~/path/to/private/key/cust1_id_ed25519

Host device01.domain.tld
        Hostname 10.0.0.1

Host device02.domain.tld
        Hostname 10.0.0.2

Host device03.domain.tld
        Hostname 10.0.0.3

I thought wildcards would only be applied to future hosts but seems like I'm wrong, thanks for reporting the issue.