SSH可从终端运行,但Jenkins无法连接

s4n0splo  于 2022-11-28  发布在  Jenkins
关注(0)|答案(1)|浏览(334)
- there are 2 containers in docker compose:
    - jenkins
    - remote_host
- there are also 2 keys:
    - id_rsa
    - id_rsa3.pub
- when remote_host is building id_rsa3.pub is coping into: home/a12/.ssh/authorized_keys
- when I connect to jenkins container via:
    - docker exec -it jenkins bash
    and try:
    - ssh -i id_rsa3 a12@remote_host -> it can connect without password
- but when I configure same Jenkins SSH with this id_rsa3:
    - Can't connect to server

SSH was generate by: ssh-keygen -t rsa -m PEM -f id_rsa3
LOGS from Jenkins show -> Auth fail and Can't connect to server

我尝试:ssh-keygen -t rsa -m PEM -f id_rsa3而不是ssh-keygen -f id_rsa3。我尝试:重新启动Jenkins服务。我尝试:从Jenkins容器终端连接到remote_host(它正在工作)我尝试:在Jenkins中重新安装SSH。

7bsow1i6

7bsow1i61#

已解决
解决方案与此主题相关:Ubuntu 22.04 SSH自20.04升级以来RSA密钥不起作用。
解决办法:

  • 我检查了remote_host服务器上的日志,发现此错误:
  • "密钥类型ssh-rsa不在PubkeyAcceptedAlgorithms中"
  • 我以这种方式生成ssh-key后:
  • 使用"ssh-keygen-t ecdsa-m PEM-f id_rsa3"代替旧版本:
  • "ssh-keygen-t rsa-m PEM-f id_rsa3"中的一个或多个。

在我的例子ssh连接开始工作。

相关问题