有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,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连接GitHub,您可以运行以下命令来确认这一点。
$git config --get remote.origin.url
如果您得到的结果格式如下:git@github.com:xxx/xxx.github.com.git,那么您应该执行以下操作。
生成SSH密钥(或使用现有密钥)。如果你有一个,你只需要将你的密钥添加到ssh-agent(步骤2)和你的GitHub帐户(步骤3)。
下面是那些没有SSH密钥的人。
步骤1生成rsa公私钥对。
$ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
系统会要求您确认保存SSH密钥的位置以及您想使用的密码短语。
步骤2在ssh-agent中添加密钥
确保ssh-agent已启用 $eval "$(ssh-agent -s)" 将SSH密钥添加到SSH -agent: ssh-add ~ / . ssh / id_rsa美元
步骤3在帐号中添加SSH密钥
安装xclip
$xclip -sel clip < ~/.ssh/id_rsa.pub
然后将复制的密钥添加到GitHub
进入“设置”->SSH密钥(个人设置侧栏)->添加SSH密钥->填写表单(密钥在剪贴板上,只需使用ctrl+v)->添加密钥
通过以上步骤,您应该可以解决权限问题。
参考链接: 生成SSH密钥。
其他回答
可能您的ssh-agent未启用 你可以试试
下载
http://git-scm.com/
安装它 使ssh-agent
C:\Program Files\Git\cmd
start-ssh-agent
您可以使用Https url登录
我猜你是试图登录SSH url 当你说git push,如果它只要求密码,考虑你是通过ssh连接。最好使用HTTP url。
如果您将ssh访问更改为https访问远程存储库,问题就解决了:
git remote set-url origin https_link_to_repository
git push -u origin master
我想我有最好的答案给你,你的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帐户。 这对我很有效。你可以试试。
这种情况会发生在创建存储库后遵循GitHub指示时。Git将指示您使用以下内容添加遥控器。
Git远程添加源git@github.com:<用户>/<项目>.git
将<>中的内容替换为与您的帐户相关的值。
解决方案是删除.git后缀。添加遥控器的操作如下:
Git远程添加origin git@github.com:<用户>/<项目>