安装在win10环境下的Jenkins添加本地虚拟机centos7作为从机遇到的问题,报错:SSH Connection failed with IOException: "Key exchange

首先声明我的Jenkins版本是:2.31版。因为不同版本页面有所不一样

安装在win10环境下的Jenkins添加本地虚拟机centos7作为从机遇到的问题,报错情况如下:

Searching for 192.168.0.104 in C:\Users\fushaolei\.ssh\known_hosts Searching for 192.168.0.104:22 in C:\Users\fushaolei\.ssh\known_hosts [04/16/20 10:04:31] [SSH] WARNING: No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file. Key exchange was not finished, connection is closed. SSH Connection failed with IOException: "Key exchange was not finished, connection is closed.", retrying in 15 seconds. There are 3 more retries left.

Searching for 192.168.0.104 in C:\Users\fushaolei\.ssh\known_hosts
Searching for 192.168.0.104:22 in C:\Users\fushaolei\.ssh\known_hosts
[04/16/20 10:04:46] [SSH] WARNING: No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file.
Key exchange was not finished, connection is closed.
SSH Connection failed with IOException: "Key exchange was not finished, connection is closed.", retrying in 15 seconds. There are 2 more retries left.
Searching for 192.168.0.104 in C:\Users\fushaolei\.ssh\known_hosts
Searching for 192.168.0.104:22 in C:\Users\fushaolei\.ssh\known_hosts
[04/16/20 10:05:01] [SSH] WARNING: No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file.
Key exchange was not finished, connection is closed.
SSH Connection failed with IOException: "Key exchange was not finished, connection is closed.", retrying in 15 seconds. There are 1 more retries left.
Searching for 192.168.0.104 in C:\Users\fushaolei\.ssh\known_hosts
Searching for 192.168.0.104:22 in C:\Users\fushaolei\.ssh\known_hosts
[04/16/20 10:05:16] [SSH] WARNING: No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file.
Key exchange was not finished, connection is closed.
ERROR: Connection is not established!
java.lang.IllegalStateException: Connection is not established!
	at com.trilead.ssh2.Connection.getRemainingAuthMethods(Connection.java:988)
	at com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPasswordAuthenticator.canAuthenticate(TrileadSSHPasswordAuthenticator.java:82)
	at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:218)
	at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:171)
	at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:863)
	at hudson.plugins.sshslaves.SSHLauncher$1.call(SSHLauncher.java:435)
	at hudson.plugins.sshslaves.SSHLauncher$1.call(SSHLauncher.java:422)
	at java.util.concurrent.FutureTask.run(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
[04/16/20 10:05:31] Launch failed - cleaning up connection
[04/16/20 10:05:31] [SSH] 连接关闭。
Warning: no key algorithms provided; JENKINS-42959 disabled
SSHLauncher{host='192.168.0.104', port=22, credentialsId='127de773-8c6b-44c6-a4cc-61ba8e7a3202', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=60, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.KnownHostsFileKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
[04/16/20 10:05:31] [SSH] Opening SSH connection to 192.168.0.104:22.
Searching for 192.168.0.104 in C:\Users\fushaolei\.ssh\known_hosts
Searching for 192.168.0.104:22 in C:\Users\fushaolei\.ssh\known_hosts
[04/16/20 10:05:31] [SSH] WARNING: No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file.
Key exchange was not finished, connection is closed.
SSH Connection failed with IOException: "Key exchange was not finished, connection is closed.", retrying in 15 seconds. There are 10 more retries left.
Searching for 192.168.0.104 in C:\Users\fushaolei\.ssh\known_hosts
Searching for 192.168.0.104:22 in C:\Users\fushaolei\.ssh\known_hosts
[04/16/20 10:05:46] [SSH] WARNING: No entry currently exists in the Known Hosts file for this host. Connections will be denied until this new host and its associated key is added to the Known Hosts file.
Key exchange was not finished, connection is closed.
SSH Connection failed with IOException: "Key exchange was not finished, connection is closed.", retrying in 15 seconds. There are 9 more retries left.

报错图如下:

 

这是为什么呢?同学们?那么问题来了,

其实很简单啦!你有一个配置配置错了,所以才会如此!

解决方案如下:

出现这个问题的根本在这个节点配置位置!如下图所示:

 

大家可以看哦,上面这个设置页面里面的启动方式只有Launch Agents Via SSH选项,而没有Launch slave Agents Via SSH选项,最后导致我只选了Launch Agents Via SSH选项和Host Key Verification Strategy的know hosts file version strategy选项。这样就会报错了,不知道为什么新版的Jenkins启动方式里面没有Launch slave Agents Via SSH,但是问题也很好解决!大家只需要把Host Key Verification Strategy选项改选为Non verifying Vervification Strategy就可以解决这个问题了!最后配置为如下图所示:

大家照着这个页面布置一下就没问题了!大可以放心!!!

下面是运行成功的代码控制台:

SSHLauncher{host='192.168.0.104', port=22, credentialsId='127de773-8c6b-44c6-a4cc-61ba8e7a3202', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=60, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.NonVerifyingKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
[04/16/20 10:26:13] [SSH] Opening SSH connection to 192.168.0.104:22.
[04/16/20 10:26:13] [SSH] WARNING: SSH Host Keys are not being verified. Man-in-the-middle attacks may be possible against this connection.
[04/16/20 10:26:13] [SSH] 认证成功。
[04/16/20 10:26:14] [SSH] The remote user's environment is:
BASH=/usr/bin/bash
BASHOPTS=cmdhist:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
BASH_ALIASES=()
BASH_ARGC=()
BASH_ARGV=()
BASH_CMDS=()
BASH_EXECUTION_STRING=set
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="4" [1]="2" [2]="46" [3]="1" [4]="release" [5]="x86_64-redhat-linux-gnu")
BASH_VERSION='4.2.46(1)-release'
DIRSTACK=()
EUID=0
GROUPS=()
HOME=/root
HOSTNAME=localhost.localdomain
HOSTTYPE=x86_64
ID=0
IFS=$' \t\n'
LANG=en_US.UTF-8
LESSOPEN='||/usr/bin/lesspipe.sh %s'
LOGNAME=root
MACHTYPE=x86_64-redhat-linux-gnu
MAIL=/var/mail/root
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
PIPESTATUS=([0]="0")
PPID=4246
PS4='+ '
PWD=/root
SELINUX_LEVEL_REQUESTED=
SELINUX_ROLE_REQUESTED=
SELINUX_USE_CURRENT_RANGE=
SHELL=/bin/bash
SHELLOPTS=braceexpand:hashall:interactive-comments
SHLVL=1
SSH_CLIENT='192.168.0.101 14404 22'
SSH_CONNECTION='192.168.0.101 14404 192.168.0.104 22'
TERM=dumb
UID=0
USER=root
XDG_RUNTIME_DIR=/run/user/0
XDG_SESSION_ID=11
_=/etc/bashrc
[04/16/20 10:26:14] [SSH] Checking java version of /root/.jenkins/jdk/bin/java
Couldn't figure out the Java version of /root/.jenkins/jdk/bin/java
bash: /root/.jenkins/jdk/bin/java: No such file or directory

[04/16/20 10:26:14] [SSH] Checking java version of java
[04/16/20 10:26:14] [SSH] java -version returned 1.8.0_242.
[04/16/20 10:26:14] [SSH] Starting sftp client.
[04/16/20 10:26:14] [SSH] 正在拷贝最新版本的 remoting.jar...
Source agent hash is E5FEC468D6F172BF394E1F2571EA686C. Installed agent hash is E5FEC468D6F172BF394E1F2571EA686C
Verified agent jar. No update is necessary.
Expanded the channel window size to 4MB
[04/16/20 10:26:14] [SSH] Starting agent process: cd "/root/.jenkins" && java  -jar remoting.jar -workDir /root/.jenkins -jar-cache /root/.jenkins/remoting/jarCache
Apr 15, 2020 10:27:09 PM org.jenkinsci.remoting.engine.WorkDirManager initializeWorkDir
INFO: Using /root/.jenkins/remoting as a remoting work directory
Apr 15, 2020 10:27:09 PM org.jenkinsci.remoting.engine.WorkDirManager setupLogging
INFO: Both error and output logs will be printed to /root/.jenkins/remoting
<===[JENKINS REMOTING CAPACITY]===>channel started
Remoting version: 4.3
This is a Unix agent
Evacuated stdout
Agent successfully connected and online

下面是连接虚拟机成功的图片:

  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

人生如路兮

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值