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

Wildcard support #23

Closed
ohdearaugustin opened this issue Jun 2, 2024 · 4 comments · Fixed by #25
Closed

Wildcard support #23

ohdearaugustin opened this issue Jun 2, 2024 · 4 comments · Fixed by #25

Comments

@ohdearaugustin
Copy link
Contributor

ohdearaugustin commented Jun 2, 2024

The plugin doesn't consider wildcard in ssh/config.

I have following configuration:

Host exx--example
  Hostname 10.10.10.10

Host exx_ exx-*
  User root
  IdenityFile ~/.ssh/key
  ForwardAgent no

The plugin then tries to connect to the host with my current username and ask for a password.

If I add the settings directly to the host like:

Host exx--example
  Hostname 10.10.10.10
  User root
  IdenityFile ~/.ssh/key
  ForwardAgent no

Everything works as expected and the key is also loaded from the ssh-agent. I need this kind of a setup as I have over 200 hosts in my configuration and the with the wildcard my config is already 1200 lines long.

Edit:
I guess the function parse_hosts_from_configs would needed to be extended to support this use-case.

@nosduco
Copy link
Owner

nosduco commented Jun 2, 2024

@ohdearaugustin Thanks for the issue report!

This is an interesting one because the plugin itself doesn't pass the SSH opts (other than Port, User, and Path) from the host files specifically, it banks on the executables themselves to read from the SSH config for the specified host. etc, if you do ssh <host> in your terminal, if the wildcards work they theoretically should work with the plugin as well...

Maybe what is happening here is because you don't have User defined for the individual hosts, then https://github.com/nosduco/remote-sshfs.nvim/blob/main/lua/remote-sshfs/connections.lua#L109 this line is overwriting it with your local user which is incorrect and thus asking for your password.

I'm debating on the best way to "detect" that it should not overwrite the username and use a different or wildcard one. Could be a configuration option, or potentially parse the SSH config files for any wildcards that match the current host and check if a User is specified. Probably would do that for Port and Path as well...

Open to suggestions! Will try and tinker with this today and early this week.

@nosduco
Copy link
Owner

nosduco commented Jun 2, 2024

https://github.com/libfuse/sshfs?tab=readme-ov-file#how-to-use

With how SSHFS works under the hood, seems like parsing for the wildcard configuration and using the User (and other options) from that is the only way since SSHFS defaults to local user if not supplied...

@ohdearaugustin
Copy link
Contributor Author

I have now tried it with sshfs itself and it seems like to work with the wildcard.

I guess the best approach would be to not fallback on the local user in the lua script. This way we would not need to parse the whole ssh config in lua. Furthermore if no user is defined in the plugin or the ssh config sshfs automatically will fallback to the local user anyway.

@nosduco
Copy link
Owner

nosduco commented Jun 11, 2024

@ohdearaugustin Nice! Thanks for the PR and thanks for the experimentation. Will get that in and released now ❤️

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

Successfully merging a pull request may close this issue.

2 participants