有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,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.
当前回答
这个答案与其他答案略有不同,但在其他情况下,您可以在系统上正确配置SSH密钥,但仍然会遇到这种情况。
我在一个孤立的环境中(例如使用Tox)在python子进程中运行git命令时遇到了这个问题。我通过传递SSH_AUTH_SOCK和SSH_AGENT_PID环境变量来修复它。
其他回答
如果您没有访问自己的存储库,或者在克隆的存储库中进行克隆(使用一些“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现在都可以在存储库页面的顶部找到。
另一个解决方案:
创建SSH密钥,输入SSH -keygen -t rsa -C "your_email@example.com"这将创建id_rsa和id_rsa。酒吧的文件。
将id_rsa添加到本地计算机的ssh列表:ssh- Add ~/.ssh/id_rsa。
生成密钥后获取pubkey使用:
cat ~/.ssh/id_rsa.pub
你会得到这样的东西:
cat ~/.ssh/id_rsa.pub
ssh-rsa AAAB3NzaC1yc2EAAAADAQABAAACAQCvMzmFEUPvaA1AFEBH6zGIF3N6pVE2SJv9V1MHgEwk4C7xovdk7Lr4LDoqEcqxgeJftwWQWWVrWWf7q9qCdHTAanH2Q5vx5nZjLB+B7saksehVOPWDR/MOSpVcr5bwIjf8dc8u5S8h24uBlguGkX+4lFJ+zwhiuwJlhykMvs5py1gD2hy+hvOs1Y17JPWhVVesGV3tlmtbfVolEiv9KShgkk3Hq56fyl+QmPzX1jya4TIC3k55FTzwRWBd+IpblbrGlrIBS6hvpHQpgUs47nSHLEHTn0Xmn6Q== user@email.com
复制这个密钥(值),到github.com,在设置(ssh和PGP密钥)下添加您的公钥。
我也遇到了和蝙蝠侠类似的问题。但是,因为我是在/usr/local/src/projectname下运行的,所以不使用sudo是不行的。
只需添加-E标志来保护环境(您的~/。ssh /路径)。
$ sudo -E git克隆git@your_repo
来自man sudo:
- e, preserve-env 指示用户希望预先设置的安全策略 服务于它们现有的环境变量。安全 如果用户没有权限,策略可能会返回错误 保护环境。
如果您将ssh访问更改为https访问远程存储库,问题就解决了:
git remote set-url origin https_link_to_repository
git push -u origin master
好吧,这个问题有一些解决方案,其中一些可能已经提到过了,但只是把它们放在一起:
确保您的键是存在的,默认情况下是另一个~/。Ssh /文件夹,即id。Rsa和id.rsa.pub 确保密钥有正确的权限,你可以运行chmod: Chmod 600 ~/.ssh/id_rsa . exe Chmod 644 ~/.ssh/id_rsa.pub 确保您的公钥(id_rsa.pub)的内容与远程存储库配置中上传的内容匹配 最后修复ssh代理的问题: ssh-add
更多信息:https://itcodehub.blogspot.com/2015/01/ssh-add-problems-with-ssh-agent-and.html