Files
gerrit/SSH签名算法问题修复.md
2025-12-22 17:12:39 +08:00

84 lines
1.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# SSH 签名算法问题修复
## 问题根源
错误信息:`no mutual signature algorithm`
这是因为 OpenSSH 10.0 默认禁用了某些旧的签名算法(如 RSA-SHA1而 Gerrit 3.3.8 使用的 Apache SSHD 可能不支持新的签名算法。
## 解决方案
### 方案一:在 SSH 配置中启用兼容算法(推荐)
在您的本地电脑上创建或编辑 SSH 配置文件:
```bash
# 编辑 SSH 配置文件
notepad ~/.ssh/config
# 或使用其他编辑器
```
添加以下内容:
```
Host 101.43.95.130
Port 29418
PubkeyAcceptedKeyTypes +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
```
保存后,重新尝试:
```bash
ssh -p 29418 renjianbo@101.43.95.130 gerrit version
```
### 方案二:在命令行中指定算法
```bash
# 使用兼容的签名算法
ssh -o PubkeyAcceptedKeyTypes=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -p 29418 renjianbo@101.43.95.130 gerrit version
```
### 方案三:生成新的 ed25519 密钥(推荐长期使用)
ed25519 密钥通常兼容性更好:
```bash
# 生成新的 ed25519 密钥
ssh-keygen -t ed25519 -C "your_email@example.com"
# 查看新公钥
cat ~/.ssh/id_ed25519.pub
```
然后将新的公钥添加到 Gerrit
1. 访问:`http://101.43.95.130:8080/#/settings/ssh-keys`
2. 添加新的 ed25519 公钥
## 快速修复(最简单)
在您的本地电脑上执行:
```bash
# 创建或编辑 SSH 配置文件
cat >> ~/.ssh/config << 'EOF'
Host 101.43.95.130
Port 29418
PubkeyAcceptedKeyTypes +ssh-rsa
PubkeyAcceptedAlgorithms +ssh-rsa
EOF
# 测试连接
ssh -p 29418 renjianbo@101.43.95.130 gerrit version
# 如果成功,推送代码
cd /d/ttt/test-project
git push origin HEAD:refs/for/master
```
## 如果还是不行
如果方案一不行,尝试方案三(生成 ed25519 密钥),通常兼容性更好。