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

Add support for ssh agent that comes with git for windows (git-bash/ cygwin) #6

Open
ncw opened this issue Oct 10, 2019 · 8 comments
Open

Comments

@ncw
Copy link

ncw commented Oct 10, 2019

As discussed on the rclone forum it would be great if this library could work with the ssh agent which comes with git-bash.

This is a packaged up version of cygwin and is very popular for running git on windows.

For example git-bash is installed on all Azure pipelines builders and GitHub actions builders by default.

I guess that in this case the library should just use the unix way of connecting to the ssh-agent. Perhaps detected by the presence of the correct environment variables?

@kylepaulsen
Copy link

So this issue is way beyond me, as I have very little systems (and golang) programming experience. I tried this little program just to see what would happen:

package main

import "fmt"
import "os"
import "net"

func main() {
	sshAuthSock := os.Getenv("SSH_AUTH_SOCK")

	conn, err := net.Dial("unix", sshAuthSock)

	if err != nil {
		fmt.Printf("Error connecting to SSH_AUTH_SOCK: %v\n", err)
		return
	}
}

I made sure to run eval `ssh-agent` and checking the env variable before running the executable, but I ended up getting this error: Error connecting to SSH_AUTH_SOCK: dial unix C:/Users/Kyle/AppData/Local/Temp/ssh-RM5AE48y6mN4/agent.1834: connect: An attempt was made to access a socket in a way forbidden by its access permissions.

Anyway, doubt this is really helpful, but i tried.

@svanharmelen
Copy link
Member

Thanks for your input @kylepaulsen. As just mentioned in issue #5 I will try to make some time for both these issues in the next week or two. Thanks.

@Silthus
Copy link

Silthus commented Aug 4, 2022

I did some debugging and I think just including the linux part in the Windows build and differentiate between them on runtime will fix Git Bash SSH_AUTH_SOCK.

@svanharmelen
Copy link
Member

I will try to make some time for both these issues in the next week or two

Right, that didn't really work out I quess 🙈

But... Doesn't this PR solve this already? It's been a while, so no clue to be honest: #7

@Silthus
Copy link

Silthus commented Aug 11, 2022

Unfortunately this doesn't work as git bash exposes the agent via the SSH_AUTH_SOCK and mimics Unix behavior.

I don't know if there even is a way to make it work.

@svanharmelen
Copy link
Member

Hi @ncw, I know its been a while but I think PR #15 should fix this issue. Is there a way you can check/verify that before I commit any changes to main? Thanks!

@FunTimeCoding
Copy link

I tried whats in PR #15, but it doesn't work.

It'll build a string like this: sshAgentPipe: \\.\pipe\C:/Users/shiin/AppData/Local/Temp/ssh-ersAr23vRV6K/agent.1270
but among the named pipes, I can't see the ssh one anyway. In my git-bash, the env variable is SSH_AUTH_SOCK=/tmp/ssh-ersAr23vRV6K/agent.1270

@svanharmelen
Copy link
Member

If you have time; did you also check or test PR #16?

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

5 participants