无法提交文件,并显示错误消息“ vs-ssh.visualstudio.com:权限被拒绝(密码,公钥)”

时间:2019-05-14 05:47:52

标签: git jenkins ssh azure-devops

我安装了Azure Devops Git,Nexus Central存储库和Jenkins。我的本地代码库在eclipse中,我希望以后再运行maven build,以便以后将快照和发行版上载到Nexus Repository。但是目前,当我在配置的项目的Jenkins Freestyle Item中运行构建时,我已经通过SSH密钥和Azure Devops Git存储库个人令牌建立了连接,这些连接到Nexus Central存储库和Azure Devops Git位置。连接成功,我可以在Jenkins中成功运行构建,即可以从Nexus中提取所有jar。但是在Jenkins构建结束时,构建报告失败,Jenkins给了我一个错误

Unable to commit files
Provider message:
The git-push command failed.
Permission denied, please try again.

***@vs-ssh.visualstudio.com: Permission denied (password,publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

我在C:\ Users ***。ssh \文件夹下生成了RSA安全密钥,该文件夹包含3个文件id_rsa(私有密钥),id_rsa.pub(公共密钥)和known_hosts。我从问题中了解到的是,我需要将SSH密钥添加到我的SSH代理中(将公钥添加到我的Azure Devops主机和known_hosts文件中),以便我的计算机知道如何尝试使用它。 我试图在Git Bash的命令下运行

$ ssh -i  ~/.ssh/id_rsa abc@***.visualstudio.com/ -v

然后我遇到如下错误

ssh: Could not resolve hostname **.visualstudio.com/: Name or service not known

尽管我已在Windows防火墙上配置了入站/出站规则并打开了所有端口,但我无法在ssh的端口22上进行通信。而且我还根据Jenkins SSH设置的需要,在环境变量中使“ HOME”用户变量指向我的用户主目录C:\ Users *** \。

请为此提供帮助,因为我不确定我在哪里做错了。

1 个答案:

答案 0 :(得分:0)

对于Windows计算机,必须在以下目录config内创建一个/c/Users/PC_USER_NAME/.ssh/文件,您可以在其中标识特定主机的密钥文件。

您可以在此处查看解决方案:How to generate multiple SSH public key and configure those on windows machine from gitbash?