有人看到这个错误并知道该怎么做吗?
我正在使用终端,我在根,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.
当前回答
如果您在连接您的企业Github帐户时遇到问题,请按照以下步骤进行
解决方案1
ERROR: git@github.com: Permission denied (public key). fatal: Could not read
from remote repository. Please make sure you have the correct access
rights
解决方案(OSX)
打开终端并执行以下命令 $ CD ~ $ sudo su ssh - keygen美元 输入要保存密钥的文件(/var/root/.ssh/id_rsa): $ id_rsa Enter passphrase(空表示没有passphrase): $ hit Enter 再次输入相同的密码:$ hit Enter $ CD ~/.ssh $ cat id_rsa.pub 复制显示内容。 打开GitHub单击您的配置文件图标设置>SSH和GPC密钥 单击新的ssh键按钮 输入您复制的任何标题和键 检查您的问题是否已经解决
解决方案2
ERROR 2: remote: Password authentication is not available for Git operations.
remote: You must use a personal access token or SSH key.
remote: See https://github.compnay.com/settings/tokens or https://github.compnay.com/settings/ssh
fatal: unable to access 'https://github.company.com/repo/app.git/': The requested URL returned an error: 403
密码认证支持已于2021年8月13日移除。请改用个人访问令牌。
https://namespaceit.com/blog/remote-support-for-password-authentication-was-removed-on-august-13-2021-please-use-a-personal-access-token-instead
其他回答
假设您正在通过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 -add -l显示存在于Github帐户的SSH密钥列表中的SSH密钥的指纹。
如果输出为空,但你知道你有一个与你的github帐户一起使用的私有SSH密钥,在这个密钥上运行SSH -add(在~/. SSH中找到。默认情况下,它被命名为id_rsa,因此您可能会运行ssh-add id_rsa)。
否则,按照下面的说明生成SSH密钥对。
这招对我很管用:
1-删除所有起源
git remote rm origin
(参见https://www.kernel.org/pub/software/scm/git/docs/git-remote.html)
*remote: "管理你所跟踪的分支的存储库集合("remotes")。
*rm: "删除已命名的远程。所有远程跟踪分支和远程配置设置都被删除。”
2-检查所有已删除:
git remote -v
3-添加新的产地主
git remote add origin git@github.com:YOUR-GIT/YOUR-REPO.git
这就是所有的朋友们!
另一个解决方案:
创建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密钥)下添加您的公钥。
我知道这个问题。添加ssh密钥后,也添加您的ssh密钥到ssh代理(来自官方文档)
ssh-agent -s
ssh-add ~/.ssh/id_rsa
一切正常工作后,git可以查看适当的密钥,以前不能。