【Jenkins添加SSH Server报错】
jenkins.plugins.publish_over.BapPublisherException: Failed to connect and initialize SSH connection. Message: [Failed to connect session for config [ansible]. Message [Auth fail for methods ‘publickey,gssapi-keyex,gssapi-with-mic,password’]]
环境:
Jenkins Server:OpenSSH_9.3p2 OpenSSL 1.1.1g
目标机器:OpenSSH_8.0p1 OpenSSL 1.1.1g
一开始以为跟openssh版本有关,后在GitHub(https://github.com/jenkinsci/publish-over-ssh-plugin/issues/312)上找到解决方案,如下:
打开Jenkins的script console,执行如下命令:
com.jcraft.jsch.JSch.setConfig("PubkeyAcceptedAlgorithms","ssh-rsa,ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256");
com.jcraft.jsch.JSch.setConfig("server_host_key","ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,rsa-sha2-512,rsa-sha2-256,ssh-rsa");
再次添加SSH Sever成功。