moul/assh

Configuration is case sensitive but many ssh versions aren't

davidpelaez opened this issue · 8 comments

Loving this tool, thanks for releasing it! However, it did give me a minor headache when I started because it's case sensitive and doesn't complain about error. I suggest that the tool either complains about unknown keys or downcases all of them before using them. In my regular config file Hostname worked, but in assh you have to write it HostName (capital N) or it won't work. This small mismatch with how things are handled by some versions of ssh could be annoying and unneeded friction.

What do you think?

moul commented

Yes, I completely agree, I also made the mistake myself :)

I will try to support insensitive keys or at least display warnings

Awesome 👍

moul commented

I opened an issue here: go-yaml/yaml#123

Depending on the resolution of this issue, I found an interesting alternative YAML library: https://github.com/BurntSushi/toml with case-insensitivity and more features

YAML is case sensitive by spec, so I don't think they will accept it if they want to provide the smallest library parsing Yaml. Maybe they could offer it as a helper or something but seems unlikely I'd say. I'll keep in tune to see how it goes. Now, Toml is way way better for this case. I was thinking about it when I saw the error. It's not space sensitive and hence is less error prone, I'd give it a +10!

moul commented

I'm not fully convinced with the TOML alternative, see: https://github.com/moul/advanced-ssh-config/pull/62/files, especially https://github.com/moul/advanced-ssh-config/blob/fix-51/README.md#configuration

What I suggest now is :

  • Handling multiple files: Yaml, TOML, json
  • Later: try to fix the Yaml parser (or fork it) to fix the key sensitivity
moul commented

Here is another pull-request which add a yaml proxy: flexyaml

  • for each lines in the yaml configuration
  • split the line on ":"
  • lowercase the left part

This is trivial but seems to work quite well

I think I can merge it for now, and remove this later

@davidpelaez: what do you think/prefer ?

moul commented

I choose the flexyaml solution, it works nicely for the moment, I hope it won't create new problems with case-insensitive hosts

@moul it works fine for me. It's simple yet clear. 👍