Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix host ordering in .ssh/config output #205

Open
pikeas opened this issue Jan 13, 2017 · 3 comments
Open

Fix host ordering in .ssh/config output #205

pikeas opened this issue Jan 13, 2017 · 3 comments
Labels
Milestone

Comments

@pikeas
Copy link

pikeas commented Jan 13, 2017

Breaking out from #190.

Example ssh config:

Host foo*.bar
    IdentityFile ~/ssh/special

Host *.bar
    User me
    IdentitifyFile ~/ssh/regular

ssh uses the first value found for each setting. This config will use the regular key for all *.bar servers but use the special key for all foo*.bar servers. But if I create the same config in assh:

hosts:
    "foo*.bar":
        identityfile: ~/ssh/special
    "*.bar":
        identityfile: ~/ssh/regular
        user: me

This generates the following config file:

Host *.bar
    IdentityFile ~/ssh/regular
    User me

Host foo*.bar
    IdentityFile ~/ssh/special

The ordering has been reversed! This will use the wrong key file for foo servers.

@moul moul added the ready label Jan 14, 2017
@moul moul self-assigned this Jan 14, 2017
@moul moul modified the milestone: v2.6.0 Jan 14, 2017
@moul moul modified the milestones: v2.6.0, v2.7.0 Feb 3, 2017
@mmlb
Copy link

mmlb commented Aug 1, 2017

@moul any pointers on this, this is biting my quite badly (but for User: config), I'd take a stab at fixing this.

@moul moul removed their assignment Sep 18, 2017
@rafi
Copy link

rafi commented Oct 27, 2019

This is the biggest drawback of assh. 😞 Instead of preserving the origin order, assh sorts the new config by alphanumeric. With regular ssh, the order is extremely important, as it can allow for wildcards+overridable variables, i.e.:

hosts:
  stg-bastion:
    User: bumblebee
    IdentityFile: ~/.ssh/acme/bumblebee

  "stg-*":
    User: optimus
    IdentityFile: ~/.ssh/acme/staging

With regular ssh, ssh stg-bastion would use bumblebee. Unfortunately with assh, the order will reverse and ssh stg-bastion would always use optimus user.

@moul Even tweaking the sorting algorithm to order * at the end would solve this, as wildcards will be placed lower than hosts with a fixed-name.

For example (sorting * as the largest character):

Host int-bastion
Host int-admin
Host int-*
Host stg-bastion
Host stg-*
Host prd-bastion
Host prd-db-01
Host prd-db-02
Host prd-*

Unfortunately now * is considered higher than a-z0-9:

Host int-*
Host int-bastion
Host int-admin
Host stg-*
Host stg-bastion
Host prd-*
Host prd-bastion
Host prd-db-01
Host prd-db-02

Any intention of solving this wildcards+overrides situation?

@moul moul modified the milestones: v2.7.0, v2 ✌ Jun 7, 2020
@Phill93
Copy link

Phill93 commented Apr 18, 2024

What is the status here? I have the same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants