beliven-it / hssh

A CLI to easily list, search and connect to SSH hosts. Sync down hosts from providers in order to get a centralized hosts configuration.
MIT License
2 stars 1 forks source link

Using Host with multiple alias hssh is unable to connect #38

Closed paolovisintin closed 1 year ago

paolovisintin commented 2 years ago

Hello!, when my ssh config has multiple aliases in Host declaration, hssh fails to connect, this is an example:


    Hostname 1.2.3.4
    Port 22
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null
    User root
    IdentityFile ~/.ssh/id_rsa
CasvalDOT commented 2 years ago

Hi! Probabily the alias doesn't work because the alias name use whitespaces. I'll check if this is the reason for this issue!

CasvalDOT commented 2 years ago

Ok! I must confirm that the issue is related to whitespaces inside alias name. For example:

Host test- lab-personal
  Hostname 1.2.3.4
  User root
  ...

When you select this host using hssh c an error occured.

bash: lab-personal: command not found
beliven-fabrizio-gortani commented 2 years ago

Ok, I've now understand the problem. HSSH should try to duplicate the host configuration in the list in this way:

# For example
Host test test2 test3
    Hostname 1.2.3.4
    Port 22
    StrictHostKeyChecking no
    UserKnownHostsFile=/dev/null
    User root
    IdentityFile ~/.ssh/id_rsa

the host list should print three entries like:

test -> 1.2.3.4
test2 -> 1.2.3.4
test3 -> 1.2.3.4

Now I'll try to understand how to implement this behavior

beliven-fabrizio-gortani commented 2 years ago

@paolovisintin I've created a Draft pull request for this feature #39. After finish some checks and tests I'll merge in master branch and create a new release.