【Git】错误:权限被拒绝(公钥)(Permission denied (publickey).)

这篇具有很好参考价值的文章主要介绍了【Git】错误:权限被拒绝(公钥)(Permission denied (publickey).)。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

项目场景:

Git项目突然不能正常使用,自己的账号下的项目。提示Permission denied (publickey).


问题描述:

附上具体配置描述如下
.ssh文件目录:
permission denied (publickey).,Git,git,github,ssh
config配置文件:

# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
# codeup.aliyun
Host codeup.aliyun.com
HostName codeup.aliyun.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/git_code_id_rsa
# coding.net
Host e.coding.net
HostName e.coding.net
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa

测试命令:

$ ssh -T git@gitee.com
Hi **! You ve successfully authenticated, but GITEE.COM does not provide shell access.
$ ssh -T git@github.com
Hi **! You ve successfully authenticated, but GitHub does not provide shell access.
$ ssh -T git@codeup.aliyun.com
Welcome to Codeup, **!
$ ssh -T git@e.coding.net
git@e.coding.net: Permission denied (publickey).

原因分析:

相同配置3个成功,1个失败,不应该是git软件问题,应该是配置问题,在mac上进行相同配置一气呵成一切都是那么完美。

 ~  ssh -T git@e.coding.net
CODING 提示: Hello **, You've connected to coding.net via SSH. This is a Personal Key.
**,你好,你已经通过 SSH 协议认证 coding.net 服务,这是一个个人公钥.
公钥指纹:94:db:5f:c3:87:fb:f7:e5:da:9b:4f:0c:8e:35:ef:2b

那为什么这台机器不能用呢,到底是哪里出了问题?好奇心驱动,继续寻找。经过百度发现GitHub SSH故障排除方法。
permission denied (publickey).,Git,git,github,ssh
图片链接地址
检查使用的密钥:发现找到私钥文件debug1: Offering public key: /c/Users/hoomi/.ssh/id_rsa RSA 错误信息为签名错误no mutual signature algorithm,原因是OpenSSH从8.8版本由于安全原因开始弃用了rsa加密的密钥

$ ssh -Tv git@e.coding.net
OpenSSH_8.9p1, OpenSSL 1.1.1n  15 Mar 2022
debug1: Reading configuration data /c/Users/hoomi/.ssh/config
debug1: /c/Users/hoomi/.ssh/config line 17: Applying options for e.coding.net
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Connecting to e.coding.net [81.69.155.167] port 22.
debug1: Connection established.
debug1: identity file /c/Users/hoomi/.ssh/id_rsa type 0
debug1: identity file /c/Users/hoomi/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.9
debug1: Remote protocol version 2.0, remote software version Go-CodingGit
debug1: compat_banner: no match: Go-CodingGit
debug1: Authenticating to e.coding.net:22 as 'git'
debug1: load_hostkeys: fopen /c/Users/hoomi/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256@libssh.org
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-rsa SHA256:jok3FH7q5LJ6qvE7iPNehBgXRw51ErE77S0Dn+Vg/Ik
debug1: load_hostkeys: fopen /c/Users/hoomi/.ssh/known_hosts2: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts: No such file or directory
debug1: load_hostkeys: fopen /etc/ssh/ssh_known_hosts2: No such file or directory
debug1: Host 'e.coding.net' is known and matches the RSA host key.
debug1: Found key in /c/Users/hoomi/.ssh/known_hosts:9
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: /c/Users/hoomi/.ssh/id_rsa RSA SHA256:/jsxB0H9in7p9/U81BTwArpeQiX4OAKGxlHqL8qnzMI explicit
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /c/Users/hoomi/.ssh/id_rsa RSA SHA256:/jsxB0H9in7p9/U81BTwArpeQiX4OAKGxlHqL8qnzMI explicit
debug1: send_pubkey_test: no mutual signature algorithm
debug1: No more authentication methods to try.
git@e.coding.net: Permission denied (publickey).

permission denied (publickey).,Git,git,github,ssh

permission denied (publickey).,Git,git,github,ssh
图片链接地址


解决方案:

config配置文件添加PubkeyAcceptedKeyTypes +ssh-rsa修改后配置文件如下

# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/gitee_id_rsa
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/github_id_rsa
# codeup.aliyun
Host codeup.aliyun.com
HostName codeup.aliyun.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/git_code_id_rsa
# coding.net
Host e.coding.net
HostName e.coding.net
PreferredAuthentications publickey
PubkeyAcceptedKeyTypes +ssh-rsa
IdentityFile ~/.ssh/id_rsa

测试命令文章来源地址https://www.toymoban.com/news/detail-520969.html

$ ssh -T git@e.coding.net
CODING 提示: Hello **, You've connected to coding.net via SSH. This is a Personal Key.
**,你好,你已经通过 SSH 协议认证 coding.net 服务,这是一个个人公钥.
公钥指纹:94:db:5f:c3:87:fb:f7:e5:da:9b:4f:0c:8e:35:ef:2b

到了这里,关于【Git】错误:权限被拒绝(公钥)(Permission denied (publickey).)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 【git问题】git同步 Permission denied (publickey).

    问题描述: 使用git clone 、git pull 等去仓库代码时,会提示 Permission denied (publickey) 。 问题定位: 如果是因为升级了mac系统到Ventura,git clone 、git pull等命令基于ssh协议,macOS Ventura内置使用了OpenSSH_9.0p1,根据OpenSSH发行说明,从OpenSSH 8.8/8.8p1 版本开始,就默认关闭了ssh-rsa算法。

    2024年02月04日
    浏览(53)
  • Git/Gerrit 提示”Permission denied (publickey).)“

    Git/Gerrit项目已经开通权限,ssh-keygen也生成并配置了,但还是不能正常使用,提示” Permission denied (publickey).“ 由于OpenSSH从8.8版本由于安全原因开始弃用了rsa加密的密钥,因为OpenSSH认为rsa破解成本已经低于5万美元,所以觉得成本太小了,有风险就给禁用了。 通过命令:ssh

    2024年02月07日
    浏览(39)
  • Git报错:git@github.com: Permission denied (publickey)

    输入指令 ssh -T git@github.com 测试SSH链接,出现如下报错: git@github.com: Permission denied (publickey,password,keyboard-interactive). git@github.com: Permission denied (publickey). git@github.com\\\'s password: ,但是即是你输入的是正确的密码,依旧提示 Permission denied, please try again. 。 在网上搜索相关解决方案,

    2024年02月02日
    浏览(46)
  • 【Git】解决 git pull 提示 Permission denied (publickey) 的问题

    在使用 ssh-keygen 创建 github 秘钥时没有使用默认文件,而是自定义了 xxx.github 的秘钥文件,然后将公钥添加到 github 上。之后发现每次 Mac 开机后使用 git pull 拉取代码时都会提示 Permission denied (publickey) 的问题,如下: 我的 Mac 电脑型号:macOS 13.2.1 。 问题的原因是没有将私钥添

    2024年02月10日
    浏览(39)
  • win10下解决git报错 Permission denied(publickey)

    今天在csdn的GitCode新建了一个项目,然后在windows下git clone时出现错误 git@gitcode.net: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. 完整报错如下图 直接说结论 因为没有把电脑的SSH public key添加到项目的gi

    2024年02月11日
    浏览(43)
  • 【git】git@github.com: Permission denied (publickey).报错问题

    本媛开发,会经常性用到gitee GitHub两个库 毕竟国内项目转战仓到gitee, 但是国外原框架还是GitHub居多 于是就出现连接pull-push经常性切换问题 这个报错是因为本地两个仓都有ssh公共私有密钥导致的 2.1.1 是因为首次本地联通没有配置密钥,或者配置错误? 如果是因为第一次配

    2024年02月11日
    浏览(44)
  • git@github.com: Permission denied (publickey). fatal: 无法读取远程仓库。

    执行git clone 命令失败,提示拒绝访问。具体解决办法如下。 (1)生成密钥,输入以下命令,一路回车即可,会生成ssh key。保存在.ssh目录下。 (2)打开刚刚生成的id_rsa.pub,将里面的内容复制,进入github,在settings下,SSH and GPG keys下new SSH key,title随便取一个名字,然后将id_rsa.p

    2024年02月11日
    浏览(41)
  • nginx 查看日志 failed (13: Permission denied) 失败(13:权限被拒绝)解决

    权限被拒绝 用户不一致: 打开  nginx.conf 文件    (一般在  etc/nginx 目录下) 把  nginx 改为 root 用户已经统一,现在可以正常访问了    

    2024年02月15日
    浏览(58)
  • git 报错:git@github.com: Permission denied (publickey).fatal: 无法读取远程仓库。

    起因: 我输入git push -u origin master 想要push到github 显示 git@github.com: Permission denied (publickey). fatal: 无法读取远程仓库。 请确认您有正确的访问权限并且仓库存在。 那么我们 第一步: 检查SSH密钥配置不正确: 确保你的本地计算机上配置了正确的 SSH 密钥。你可以通过以下步骤检

    2024年02月04日
    浏览(46)
  • git报错:Permission denied (publickey). fatal: Could not read from remote repository.

    背景 :由于新换了电脑,新装了git,所以在用git拉取代码的时候就出现了标题一样的错误 ternimal下出现下面错误: Permissiondenied (publickey). fatal:Could not read from remote repository. Pleasemake sure you have the correct access rights and the repository exists. 分析原因 : 原因是由于你在本地(或者服务

    2024年02月05日
    浏览(38)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包