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

Give precedence ~/.ssh/config file over $SSH_AUTH_SOCK + ability set custom SSH socket path #57

Open
Dentrax opened this issue Sep 19, 2023 · 0 comments

Comments

@Dentrax
Copy link

Dentrax commented Sep 19, 2023

Follow-up issue for: #26 (comment)


By default, goph only respects SSH_AUTH_SOCK environment variable and ignores default SSH config path. This causes incorrect behavior compared to how ssh works.

case goph.HasAgent():
		auth, err = goph.UseAgent()

ssh respects ~/.ssh/config and checks if there Host * host, then uses IdentityAgent.

We should reconsider how HasAgent will work:

func HasAgent() bool {
	return os.Getenv("SSH_AUTH_SOCK") != ""
}

We could use https://github.com/kevinburke/ssh_config to check if ssh_config.Get("*", "IdentityFile") has any value. If so, give precedence to it.

Also, we should add a new arg to use custom SSH agent socket path:

func UseAgent() (Auth, error) 

This function enforces us to set $SSH_AUTH_SOCK, but we'd prefer to set optional SSH agent socket path.

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

No branches or pull requests

1 participant