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?
Steps to connect GitHub to SSH :Open the GitHub website and log in to your account. Go to the settings page from the menu in top right corner. Select “SSH and GPG keys” from the sidebar and click on “New SSH key” option. Add relevant title in the “Title” field and paste the SSH key in the “Key field“.
Git can use four distinct protocols to transfer data: Local, HTTP, Secure Shell (SSH) and Git.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With