首页 > 解决方案 > VS Code 源代码控制功能在远程身份验证上失败

问题描述

问题:
由于身份验证问题,无法在 VS Code 上使用源代码管理功能

设置:
在 Windows 笔记本电脑上编辑,然后通过 VS Code 的 SSH 扩展远程连接到 linux 服务器。Git repo 是在 linux 服务器上设置的。我能够推/拉/等等。通过命令行到 repo,但源代码控制功能失败。出现以下错误:

Permission denied, please try again.
Permission denied, please try again.
git@[company gitlab domain]: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: Could not read from remote repository.

我试图重新生成 SSH 密钥,但这并没有解决问题。Windows 中的凭据也设置正确。

标签: pythongitlabssh-keysvscode-remote

解决方案


Windows 中的凭据也设置正确。

如果通过“凭据”,您正在谈论缓存在 中的用户名/密码git config credential.helper,那根本无助于 SSH,因为这仅用于 HTTPS URL。

我能够推/拉/等等。通过命令行到 repo,但源代码控制功能失败。

从 Linux 服务器的命令行仔细检查该 Git 存储库的根文件夹中的远程 eURL:

git remote origin

确保它是 SSH 的

您可以将其替换为:

gl:<me>/<myrepo>

gl远程帐户中设置了一个条目~/.ssh/config

Host gl
  Hostname: [company gitlab domain]
  User: git
  IdentityFile: /home/aUser/.ssh/aKey

推荐阅读