有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,GitHub存储库存在,我不知道现在该做什么。
> git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,GitHub存储库存在,我不知道现在该做什么。
> git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
当前回答
如果您没有访问自己的存储库,或者在克隆的存储库中进行克隆(使用一些“git submodule…”“命令):
在存储库的主目录中:
$ ls -a
1. 开放”。,你会发现这样的东西:
[submodule "XXX"]
path = XXX
url = git@github.com:YYY/XXX.git
将最后一行更改为您需要提取的存储库的HTTPS:
[submodule "XXX"]
path = XXX
https://github.com/YYY/XXX.git
保存”。“Gitmodules”,并为子模块运行命令。Git”将被更新。
2. 开放”。Git”,转到“config”文件,你会发现这样的东西:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
ignorecase = true
precomposeunicode = true
[remote "origin"]
url = https://github.com/YYY/XXX.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[submodule "XXX"]
url = git@github.com:YYY/XXX.git
将最后一行更改为您需要提取的存储库的HTTPS:
url = https://github.com/YYY/XXX.git
因此,在本例中,主要问题只是url。任何存储库的HTTPS现在都可以在存储库页面的顶部找到。
其他回答
这发生在我身上。出于某种原因,我的出身在我没有意识到的情况下被搞砸了:
检查您的设置是否仍然正确
git remote -v
url需要像ssh://git@github.com/YourDirectory/YourProject.git; 如果没有看到git@github.com,请使用
git remote set-url origin git://github.com/YourDirectory/YourProject.git
纠正错误。或者你可以使用github应用程序在特定存储库的设置面板中检查和设置主远程存储库url。
我想我有最好的答案给你,你的git应用程序读取你的id_rsa。根用户目录下的Pub
/home/root/.ssh/id_rsa.pub
这就是为什么你的密钥在/home/your_username/.ssh/id_rsa中。少年犯看不懂酒吧。因此,您需要在/home/root/.ssh/中创建密钥
$ sudo su
$ ssh-keygen
$ cd ~/.ssh
$ cat id_rsa.pub
然后复制密钥在你的github帐户。 这对我很有效。你可以试试。
如果您正在使用windows -10,请遵循此说明。这对我很管用。
以管理员身份打开终端 执行命令:"ssh-keygen"。它生成一个ssh密钥,并显示创建密钥的文件夹。检查我的图像 复制生成的ssh密钥 点击“新建SSH键按钮”并粘贴“SSH键”,最后“点击添加按钮”
对我来说,我试过这个
eval "$(ssh-agent -s)"
然后我就跑
ssh-add ~/.ssh/path-to-the-keyfile
为了生成密钥,你可以运行
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
这将生成一对密钥(Public和private)。
您可以将此密钥存储到github以了解更多信息,添加一个新的SSH密钥到您的github帐户
我希望它能帮助到其他人:)
我最近也遇到了同样的问题。如果您需要立即修复,这可能会有所帮助,但每次重新启动系统时都需要这样做
在终端执行:ssh-add ~/.ssh/id_rsa
输入系统密码就可以了。