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

Configure ssh.clientOptions using environment variables. Fixes go-git#411. #517

Conversation

smveloso
Copy link

I stumbled upon #411 (which is actually caused by golang/go#29286) and I did not like the idea of relying solely on editing the "known_hosts" file as a workaround. So I tried to see if I could set ssh client parameters in code.

Although a work in progress, I think this might be a worthy (very small) contribution.

I chose to do it with environment variables at first to minimize changes in existing code, but I also think this approach may be better suited for applications that use go-git in container environments (as opposed to a configuration file) and ones that deal with a limited set of remote repositories.

Maybe a more general approach might be reading a standard ssh client (ssh_config) file; the file format already allows setting different parameters for different remote hosts. However, in containers/kubernetes scenarios, creating a file and making it available as a volume seems to be too much, unless you really need many different "profiles" in your use case.

@smveloso
Copy link
Author

I think the other approaches would be:

  1. Add a field to every struct that is used as argument in functions that might result in ssh operations So, for example, CloneOptions would have an "SSHClientOptions" field.

  2. Wait for golang's ssh library to implement auto-configuration (set "HostKeyAlgorithms" according to what is available in the known_hosts file(s)).

  3. Implement auto-configuration directly in go-git.

Option "3" unfortunately won't be able to leverage code from golang's "x/crypto/ssh/knownhosts" package, because the relevant parts that process "known_hosts" files are not public.

@smveloso smveloso marked this pull request as ready for review April 22, 2022 20:11
@mcuadros
Copy link
Member

Fixed by #548

@mcuadros mcuadros closed this Sep 22, 2022
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 this pull request may close these issues.

None yet

2 participants