Jes*_*sie 16 git github git-push
我创建了一个新的远程仓库,并试图使用git push -u origin master
命令后,我对我的本地文件推到新的存储库中的第一次add
它和commit
它。然而,它弹出这个git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
。我该如何修复这个致命错误?
我已经尝试过
使用 Git 时如何解决 Permission denied (publickey) 错误?
此链接中的问题似乎发生在第一次使用 git 时。我已经使用我的 git 一段时间了,我还需要遵循这个解决方案吗?谁能给我一个更具体的解决方案?
这是我得到的致命错误
C:\Users\ASUS\Desktop\React-Practice App\my-app>git status
On branch master
nothing to commit, working tree clean
C:\Users\ASUS\Desktop\React-Practice App\my-app>git push -u origin master
git@github.com: 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)
小智 52
我遇到这个问题是因为我像 @Mon 一样使用了非标准位置的密钥。就我而言,我没有使用默认文件名,因为我的系统上有多个密钥。所以单纯通过移动或者重命名是无法解决的。
解决方案是编辑或创建~/.ssh/config
(OpenSSH 文档config
和配置身份密钥的位置)以包含以下内容:
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/github-key
Run Code Online (Sandbox Code Playgroud)
不要编辑第 3 行来反映您自己的用户名。用户名应该是git
(参见github 文档)。
编辑第 4 行以反映密钥的位置。
如果您已经有一个config
文件,那么在乱搞之前看看里面有什么是值得的。在编辑之前制作一份副本总不会有什么坏处。
上面假设你已经创建了密钥,把它放在github上,你实际上确实有权限,其他一切都应该是这样,但仍然遇到错误。
Eri*_*ric 24
即使在 github 上添加 ssh 密钥后也遇到同样的问题。
通过运行此命令修复它
ssh -vT git@github.com
moa*_*zem 23
您正在通过 SSH 访问 GitHub。首先生成一个SSH密钥对;然后将公钥添加到 GitHub。
生成密钥对:
ssh-keygen -t rsa -b 4096 -C “youremail@example.com”
Run Code Online (Sandbox Code Playgroud)
在https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent和https://help.github.com查看更多/en/articles/adding-a-new-ssh-key-to-your-github-account
归档时间: |
|
查看次数: |
31790 次 |
最近记录: |