通过SSH隧道访问Git仓库

编程入门 行业动态 更新时间:2024-10-26 10:35:00
本文介绍了通过SSH隧道访问Git仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有权访问可以访问GIT服务器的SSH帐户,并能够在此SSH登录中克隆/推/拉回购。然而,我无法从别处访问此回购。

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.

在我使用的SSH账户中,

On the SSH account I use,

git clone git@gitserver:proj/myrepo.git

克隆回购。

我尝试使用另一台机器设置一个ssh隧道到git服务器,

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

然而,我一直提示输入用户'git'的密码。任何想法我在这里做错了吗?

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

推荐答案

当您这样做时:

When you do this:

git clone git@gitserver:proj/myrepo.git

ssh客户端在本地主机('sshserver')上启动,并使用公钥认证与'gitserver'进行身份验证。如果提示输入用户'git'的密码,那意味着公钥认证失败,并且ssh正在进入下一个方法,即密码认证。

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.

公钥认证失败的最可能原因是ssh客户端没有所需的私钥。我在这种情况下,关键需要作为git的@ gitserver认证怀疑存在于sshserver:的〜/ .ssh,在这种情况下,当您试图克隆回购,将无法使用ssh客户端开始你的本地主机上通过你的ssh隧道。

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.

为了解决这个问题,你需要让客户端访问合适的密钥。您可以将它添加到〜/ .ssh本地,或将其加载到ssh代理中。

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.

更多推荐

通过SSH隧道访问Git仓库

本文发布于:2023-10-07 12:42:13,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:隧道   仓库   SSH   Git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!