相关疑难解决方法(0)

使用Visual Studio 2017通过SSH连接到Git存储库

我正在尝试使用Visual Studio 2017中的SSH连接到Git存储库(在Bitbucket上)(据我所知,它支持用于Git的SSH).我已经设置了所有东西,将存储库克隆到我的计算机上,然后我可以提交,但是如果我尝试执行某些操作,则会使用以下消息(来自Visual Studio的"输出"窗口)失败:

Error encountered while fetching: Git failed with a fatal error.
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)

从命令提示符尝试它,我得到这些稍微提供信息的消息:

Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

从Git Bash我尝试打开SSH代理,添加我的私钥和获取,它似乎工作(或者至少我没有得到任何消息,不像代理未启动或未添加密钥):

eval `ssh-agent`
ssh-add ~/.ssh/xxxx
git fetch
Run Code Online (Sandbox Code Playgroud)

但是Visual Studio仍然无法连接.我也尝试从Windows命令提示符执行相同的操作:

ssh-agent
set SSH_AUTH_SOCK=/tmp/ssh-SIAryCa61iz9/agent.11128
set SSH_AGENT_PID=9804
ssh-add xxxx
git fetch
Run Code Online (Sandbox Code Playgroud)

但我仍然得到同样的错误.

我已经将公钥添加到Bitbucket,并ssh -T git@bitbucket.org输出"以xxxx登录".此外,我可以使用SourceTree正确连接并将私钥添加到Pageant(我使用的密钥ssh-add具有所需的OpenSSH格式,我是从.ppk格式创建的).

git ssh visual-studio-2017

14
推荐指数
3
解决办法
3万
查看次数

Jenkins:Credentials中私钥的正确格式是什么

我正在Windows Server 2016上运行的Jenkins 2.152中创建一个工作,需要从bitbucket.org上托管的git repo中提取.我通过git-bash测试了ssh密钥,所以我知道它有效并且没有密码短语.当我尝试使用与Jenkins完全相同的私钥时,我收到一条错误消息.

Failed to connect to repository : Command "git.exe ls-remote -h 
git@bitbucket.org:mygroup/myrepo HEAD" returned status code 128:
stdout: 
stderr: Load key 
"C:\\Users\\JE~1\\AppData\\Local\\Temp\\ssh2142299850576289882.key": invalid format 
git@bitbucket.org: Permission denied (publickey). 
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

凭据设置为

 scope: Global
 user: git
 Private Key -> Enter Directly -> copy and past - generated by ssh-keygen -t rsa in gitbash
 Passphrase: empty
 ID: empty
 description: bitbucket.org …
Run Code Online (Sandbox Code Playgroud)

git ssh bitbucket jenkins

10
推荐指数
4
解决办法
6181
查看次数

标签 统计

git ×2

ssh ×2

bitbucket ×1

jenkins ×1

visual-studio-2017 ×1