Help us learn about your current experience with the documentation. Take the survey.
SSH 故障排除
在使用 SSH 密钥时,你可能会遇到以下问题。
TLS:服务器发送的证书包含大于 8192 位的 RSA 密钥
在 GitLab 16.3 及更高版本中,Go 将 RSA 密钥限制为最大 8192 位。 要检查密钥长度:
openssl rsa -in <your-key-file> -text -noout | grep "Key:"将任何超过 8192 位的密钥替换为较短的密钥。
git clone 时出现密码提示
当你运行 git clone 时,可能会被提示输入密码,例如 git@gitlab.example.com's password:。
这表明你的 SSH 设置有问题。
- 确保你正确生成了 SSH 密钥对,并将公钥添加到了你的 GitLab 配置文件中。
- 确保你的 SSH 密钥格式与你的服务器操作系统配置兼容。例如,ED25519 密钥对在某些 FIPS 系统上可能无法工作。
- 尝试使用
ssh-agent手动注册你的私钥。 - 尝试通过运行
ssh -Tv git@example.com来调试连接。 将example.com替换为你的 GitLab URL。 - 确保你遵循了在 Microsoft Windows 上使用 SSH中的所有说明。
- 确保验证 GitLab SSH 所有权和权限。如果你有多个主机,请确保所有主机的权限都正确。
Could not resolve hostname 错误
当你验证是否可以连接时,可能会收到以下错误:
ssh: Could not resolve hostname gitlab.example.com: nodename nor servname provided, or not known如果收到此错误,请重启终端并再次尝试该命令。
Key enrollment failed: invalid format 错误
当你为 FIDO2 硬件安全密钥生成 SSH 密钥对时,可能会收到以下错误:
Key enrollment failed: invalid format你可以尝试以下方法进行故障排除:
- 使用
sudo运行ssh-keygen命令。 - 验证你的 FIDO2 硬件安全密钥支持提供的密钥类型。
- 通过运行
ssh -V验证 OpenSSH 版本是否为 8.2 或更高版本。
错误:SSH 主机密钥在此系统上不可用。
如果 GitLab 无法访问主机 SSH 密钥,当你访问 gitlab.example/help/instance_configuration 时,你会在 SSH 主机密钥指纹 标题下看到以下错误消息,而不是实例 SSH 指纹:
SSH host keys are not available on this system. Please use ssh-keyscan command or contact your GitLab administrator for more information.要解决此错误:
- 在 Helm chart(Kubernetes)部署中,更新
values.yaml,在webservice部分下将sshHostKeys.mount设置为true。 - 在 GitLab 自托管实例上,检查
/etc/ssh目录中的主机密钥。