ubuntu-2204 gerrit ssh 报错Permission denied (publickey).分析及解决

这篇具有很好参考价值的文章主要介绍了ubuntu-2204 gerrit ssh 报错Permission denied (publickey).分析及解决。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

ubuntu-2204 gerrit ssh 报错Permission denied (publickey).分析及解决

使用repo init/sync下载代码时遇到报错: Permission denied (publickey).

分析排查步骤

通过以下步骤排查

以下user10.100.1.115为化名

$ ssh -p 29418 user@10.100.1.115

The authenticity of host '[10.100.1.115]:29418 ([10.100.1.115]:29418)' can't be established.
ED25519 key fingerprint is SHA256:YmW8pF9ZuvIBcT6qWr5Q72zTP7RBVoGcovSKth6uFWo.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '[10.100.1.115]:29418' (ED25519) to the list of known hosts.
user@10.100.1.115: Permission denied (publickey).

查看详细信息
$ ssh -vv -p 29418 user@10.100.1.115

OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname 10.100.1.115 is address
debug1: Connecting to 10.100.1.115 [10.100.1.115] port 29418.
debug1: Connection established.
debug1: identity file /home/user/.ssh/id_rsa type 0
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: identity file /home/user/.ssh/id_ecdsa type -1
debug1: identity file /home/user/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/user/.ssh/id_ecdsa_sk type -1
debug1: identity file /home/user/.ssh/id_ecdsa_sk-cert type -1
debug1: identity file /home/user/.ssh/id_ed25519 type -1
debug1: identity file /home/user/.ssh/id_ed25519-cert type -1
debug1: identity file /home/user/.ssh/id_ed25519_sk type -1
debug1: identity file /home/user/.ssh/id_ed25519_sk-cert type -1
debug1: identity file /home/user/.ssh/id_xmss type -1
debug1: identity file /home/user/.ssh/id_xmss-cert type -1
debug1: identity file /home/user/.ssh/id_dsa type -1
debug1: identity file /home/user/.ssh/id_dsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3
debug1: Remote protocol version 2.0, remote software version GerritCodeReview_3.2.7 (APACHE-SSHD-2.4.0)
debug1: compat_banner: no match: GerritCodeReview_3.2.7 (APACHE-SSHD-2.4.0)
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to 10.100.1.115:29418 as 'user'
debug1: load_hostkeys: fopen /home/user/.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
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,sntrup761x25519-sha512@openssh.com,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group14-sha256,ext-info-c
debug2: host key algorithms: ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,sk-ssh-ed25519-cert-v01@openssh.com,sk-ecdsa-sha2-nistp256-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,sk-ssh-ed25519@openssh.com,sk-ecdsa-sha2-nistp256@openssh.com,rsa-sha2-512,rsa-sha2-256
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none,zlib@openssh.com,zlib
debug2: compression stoc: none,zlib@openssh.com,zlib
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: ecdh-sha2-nistp521,ecdh-sha2-nistp384,ecdh-sha2-nistp256,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group18-sha512,diffie-hellman-group17-sha512,diffie-hellman-group16-sha512,diffie-hellman-group15-sha512,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1
debug2: host key algorithms: ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug2: ciphers ctos: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc
debug2: ciphers stoc: aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc,blowfish-cbc,aes192-cbc,aes256-cbc
debug2: MACs ctos: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
debug2: MACs stoc: hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1,hmac-md5,hmac-sha1-96,hmac-md5-96
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos: 
debug2: languages stoc: 
debug2: first_kex_follows 0 
debug2: reserved 0 
debug1: kex: algorithm: ecdh-sha2-nistp256
debug1: kex: host key algorithm: ssh-ed25519
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256-etm@openssh.com compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: SSH2_MSG_KEX_ECDH_REPLY received
debug1: Server host key: ssh-ed25519 SHA256:YmW8pF9ZuvIBcT6qWr5Q72zTP7RBVoGcovSKth6uFWo
debug1: load_hostkeys: fopen /home/user/.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 '[10.100.1.115]:29418' is known and matches the ED25519 host key.
debug1: Found key in /home/user/.ssh/known_hosts:1
debug2: ssh_set_newkeys: mode 1
debug1: rekey out after 4294967296 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug2: ssh_set_newkeys: mode 0
debug1: rekey in after 4294967296 blocks
debug1: get_agent_identities: bound agent to hostkey
debug1: get_agent_identities: agent returned 1 keys
debug1: Will attempt key: /home/user/.ssh/id_rsa RSA SHA256:bansqueqJ/in2VZCOhLH8qQbALzUhWiHySt3gePFYds agent
debug1: Will attempt key: /home/user/.ssh/id_ecdsa 
debug1: Will attempt key: /home/user/.ssh/id_ecdsa_sk 
debug1: Will attempt key: /home/user/.ssh/id_ed25519 
debug1: Will attempt key: /home/user/.ssh/id_ed25519_sk 
debug1: Will attempt key: /home/user/.ssh/id_xmss 
debug1: Will attempt key: /home/user/.ssh/id_dsa 
debug2: pubkey_prepare: done
debug2: service_accept: ssh-userauth
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: /home/user/.ssh/id_rsa RSA SHA256:bansqueqJ/in2VZCOhLH8qQbALzUhWiHySt3gePFYds agent
debug1: send_pubkey_test: no mutual signature algorithm
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/user/.ssh/id_ed25519
debug1: Trying private key: /home/user/.ssh/id_ed25519_sk
debug1: Trying private key: /home/user/.ssh/id_xmss
debug1: Trying private key: /home/user/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
user@10.100.1.115: Permission denied (publickey).

通过以上详细信息可以看到以下几个关键点

  • OpenSSH版本为 OpenSSH_8.9p1
  • 失败的具体原因为
debug1: Next authentication method: publickey
debug1: Offering public key: /home/user/.ssh/id_rsa RSA SHA256:bansqueqJ/in2VZCOhLH8qQbALzUhWiHySt3gePFYds agent
debug1: send_pubkey_test: no mutual signature algorithm
debug1: Trying private key: /home/user/.ssh/id_ecdsa
debug1: Trying private key: /home/user/.ssh/id_ecdsa_sk
debug1: Trying private key: /home/user/.ssh/id_ed25519
debug1: Trying private key: /home/user/.ssh/id_ed25519_sk
debug1: Trying private key: /home/user/.ssh/id_xmss
debug1: Trying private key: /home/user/.ssh/id_dsa
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
user@10.100.1.115: Permission denied (publickey).
  • 验证publickey时,本地提供了私钥/home/user/.ssh/id_rsa,但是no mutual signature algorithm 无互签名算法,尝试ed25529等算法但是没有匹配的认证方式。
  • 解决办法是提供ecdsa,ed25519,dsa等算法的公钥和私钥对。

深层次原因及解决方法

OpenSSH 8.8 考虑到cryptographically broken,开始禁用了使用SHA-1哈希算法的RSA签名算法。
这是一个客户端限制。我们必须提供能被OpenSSH 8.8认可的密钥类型,比如 OpenSSH 推荐的Ed25519

配置方法如下:

  1. 生成ed25519密钥
    ssh-keygen -t ed25519 -C "your_email@example.com"
    将私钥添加到身份验证代理
    ssh-add

  2. ~/.ssh/id_ed25519.pub的文本添加到gerritgit用户配置的SSH keys

  • cat ~/.ssh/id_ed25519.pub
  • Click the setting button
  • Click the SSH Public Keys button
  • Click the Add key button
  • Add the info of the public key and save.
  1. 可以在~/.ssh/config配置文件中指定认证选项,明确指定认证文件(不是必须的)
    比如:
Host your.gerrit.host
IdentityFile ~/.ssh/id_ed25519
  1. 或者在$HOME/.ssh/config配置文件中指定客户端接受RSA密钥(不推荐)
PubkeyAcceptedKeyTypes +ssh-rsa

文章来源地址https://www.toymoban.com/news/detail-487407.html

Host *
ServerAliveInterval 120

IdentityFile ~/.ssh/id_ed25519
IdentityFile ~/.ssh/id_rsa
PubkeyAcceptedKeyTypes +ssh-rsa

到了这里,关于ubuntu-2204 gerrit ssh 报错Permission denied (publickey).分析及解决的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

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

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

相关文章

  • gitLab在配置完ssh密钥后依然提示Permission denied (publickey)

    使用gitlab之前已经在gitHub将密钥配置后,在使用git clone拉取代码的时候依然报错,尝试分别用ssh和http拉取都是相同报错,使用cat ~/.ssh/id_rsa.pub查看公钥没有问题,在这个情况下可能就是公钥目录存在问题 解决办法

    2024年02月13日
    浏览(38)
  • 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日
    浏览(44)
  • 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日
    浏览(47)
  • 【git】git@github.com: Permission denied (publickey).报错问题

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

    2024年02月11日
    浏览(45)
  • ssh时提示:Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).

    一、报错现象: 二、SSH原理 SSH或Secure Shell,是一种通常通过命令行安全访问远程计算机的非常常用的方法。它旨在确保连接以及所有传递的数据都不会被窃听。为了达到这个目的,常见的SSH客户端(例如OpenSSH)内置了许多检查,以确保我们发起的连接的安全性不会受到损害

    2024年02月12日
    浏览(38)
  • 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)
  • 终极办法!connect to host port 22: Connection timed out git@ssh.github.com: Permission denied (publickey

    过了个周末git突然用不了了,在拉代码的时候突然报错连接超时,又报错说没有权限,这就很烦了 在百度了很久以后尝试了各种办法,重新生成pub_key,重装git等等都没能解决,最后询问了公司大佬,困扰了一个上午的问题终于解决了 先说说百度上的解决办法: 使用命令 s

    2024年02月04日
    浏览(43)
  • 使用gitee上传代码报错:git@gitee.com: Permission denied (publickey),如何配置GitEE公钥

    git@gitee.com: Permission denied (publickey). Could not read from remote repository.  Please make sure you have the correct access rights and the repository exists. Permission denied (publickey) 没有权限的publickey(公锁) ,出现这错误一般是以下两种原因: 客户端与服务端未生成 ssh key 客户端与服务端的ssh key不匹配 找到

    2024年02月05日
    浏览(42)
  • git克隆报错:Permission denied (publickey).fatal: Could not read from remote repository解决办法

    Permission denied (publickey).fatal: Could not read from remote repository 1、问题解决首先参考文章 例如:缺少公钥解决办法 2、生成公钥报错 ssh-keygen -t rsa -C ‘邮箱’ 生成公钥时,报错如下: 解决办法: 需要换到C盘的C:UsersASUS.ssh目录下,再右键Git Bash Here 输入命令: ssh-keygen -t rsa -C \\\'

    2024年02月04日
    浏览(45)

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

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

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

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

二维码1

领取红包

二维码2

领红包