Pergunta

I have access to an SSH account that can access a GIT server and am able to clone/push/pull the repo in this SSH login. However I cannot access this repo from elsewhere.

On the SSH account I use,

git clone git@gitserver:proj/myrepo.git

to clone the repo.

I tried setting up a ssh tunnel to the git server from another machine using,

ssh -L 3333:gitserver:22 userid@sshserver
git clone ssh://localhost:3333/proj/repo.git

However I keep getting prompted for a password for the user 'git'. Any ideas what I am doing wrong here?

Foi útil?

Solução

When you do this:

git clone git@gitserver:proj/myrepo.git

an ssh client is starting on the local host ('sshserver') and authenticating with 'gitserver' using public key authentication. If you get prompted for a password for user 'git', that means public key authentication has failed, and ssh is falling through to the next method, which is password authentication.

The most likely reason that public key authentication would fail is that the ssh client does not have the private key needed. I suspect in this case that the key needed to authenticate as 'git@gitserver' resides in sshserver:~/.ssh, in which case it would not be available to the ssh client started on your local host when you try to clone the repo through your ssh tunnel.

To solve this, you need to give that client access to the appropriate key. You could add it to ~/.ssh locally, or load it into an ssh agent.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top