使用SSH RSA 算法和git@192.168.31.41:35022/group1/demo-ops.git 方式在部署应用的时候会遇到异常:
Unable to create application: application spec for demo is invalid: InvalidSpecError: Unable to generate manifests in demo: rpc error: code = Internal desc = Failed to fetch default: `git fetch origin --tags --force --prune` failed exit status 128: Warning: Permanently added '192.168.31.41' (ED25519) to the list of known hosts. Permission denied, please try again. Permission denied, please try again. git@192.168.31.41: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
解决办法:
使用ssh ed25519 加密算法和
ssh://git@192.168.31.41:35022/group1/demo-ops.git
仓库连接地址。
原因参考官方文档:
Private Repositories - Argo CD - Declarative GitOps CD for Kubernetes
Private repositories that require a username and password typically have a URL that start with https:// rather than git@ or ssh://.
Note
Argo CD 2.4 upgraded to OpenSSH 8.9. OpenSSH 8.8 dropped support for the ssh-rsa SHA-1 key signature algorithm. See the 2.3 to 2.4 upgrade guide for details about testing SSH servers for compatibility with Argo CD and for working around servers that do not support newer algorithms.
https://www.openssh.com/txt/release-8.8
ssh-rsa sha-1 证书不被支持。
When your SSH repository is served from a non-standard port, you have to use ssh://-style URLs to specify your repository. The scp-style git@yourgit.com:yourrepo URLs do not support port specification, and will treat any port number as part of the repository's path.
不能使用git@192.168.31.41:35022 格式来增加端口号,而是 ssh://git@192.168.31.41:35022/group1/demo-ops.git
Git 证书设置办法:
对应的git仓库创建对应的depoly keys,depoly keys的详细说明可以参考gitlab的官方文档。depoly keys可以在gitlab的仓库的Settings -> Repository -> Deploy keys找到,然后把刚刚生成的key里面的公钥放进去即可。