configuration of a slave node in jenkins with SSH-Agent - jenkins

Hello everubody , i have this problem when i want to configure a slave node in jenkins with the SSH-agent method , can you help me to resolve this problem ?
11/01/17 12:16:15] [SSH] Opening SSH connection to 192.168.226.197:22.
/var/lib/jenkins/.ssh/known_hosts [SSH] No Known Hosts file was found at /var/lib/jenkins/.ssh/known_hosts. Please ensure one is created at this path and that Jenkins can read it.
Key exchange was not finished, connection is closed.
java.io.IOException: There was a problem while connecting to 192.168.226.197:22
at com.trilead.ssh2.Connection.connect(Connection.java:834)
at com.trilead.ssh2.Connection.connect(Connection.java:703)
at com.trilead.ssh2.Connection.connect(Connection.java:617)
at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1284)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:804)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:793)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: Key exchange was not finished, connection is closed.
at com.trilead.ssh2.transport.KexManager.getOrWaitForConnectionInfo(KexManager.java:95)
at com.trilead.ssh2.transport.TransportManager.getConnectionInfo(TransportManager.java:237)
at com.trilead.ssh2.Connection.connect(Connection.java:786)
... 9 more
Caused by: java.io.IOException: The server hostkey was not accepted by the verifier callback
at com.trilead.ssh2.transport.KexManager.handleMessage(KexManager.java:548)
at com.trilead.ssh2.transport.TransportManager.receiveLoop(TransportManager.java:790)
at com.trilead.ssh2.transport.TransportManager$1.run(TransportManager.java:502)
... 1 more
[11/01/17 12:16:15] Launch failed - cleaning up connection
[11/01/17 12:16:15] [SSH] Connection closed.

In your agent configuration, for "Host Key Verification Strategy" you probably have "Known hosts file verification strategy".
But when master initiates ssh connection - it doesn't update the known host file.
So, you can try to execute ssh command manually to initiate a connection and update the file appropriately.
And of course you can disable "Know hosts file verification strategy" by setting "Non verifying Verification Strategy", but it is insecure.

No Known Hosts file was found at /var/lib/jenkins/.ssh/known_hosts. Please ensure one is created at this path and that Jenkins can read it.
On the Master’s machine, you can use ssh-copy-id command connect to agent:
ssh-copy-id [-p agent-ssh-port] agent-user#agent-hostname
On the Master, Relaunch the agent in Jenkins Nodes.

Related

Cannot ssh from master to slave node in Jenkins 2.235

I am able to ssh into the node machine via terminal, using ssh jenkins#192.168.50.2. But when I try to connect a node using Jenkins, here using Jenkins GUI, I am getting the following error message. I searched for this and it was an old issue with some jenkins 1.x.x version. Am I doing something wrong with Jenkins setup? Or is a similar bug in the latest version of Jenkins too?.
SSHLauncher{host='192.168.50.2', port=22, credentialsId='3722a835-e9b3-4030-a13f-d5911bef2524', jvmOptions='', javaPath='', prefixStartSlaveCmd='', suffixStartSlaveCmd='', launchTimeoutSeconds=60, maxNumRetries=10, retryWaitTime=15, sshHostKeyVerificationStrategy=hudson.plugins.sshslaves.verifiers.KnownHostsFileKeyVerificationStrategy, tcpNoDelay=true, trackCredentials=true}
[08/27/20 20:20:44] [SSH] Opening SSH connection to 192.168.50.2:22.
Searching for 192.168.50.2 in /var/lib/jenkins/.ssh/known_hosts
Searching for 192.168.50.2:22 in /var/lib/jenkins/.ssh/known_hosts
[08/27/20 20:20:44] [SSH] SSH host key matches key in Known Hosts file. Connection will be allowed.
[08/27/20 20:20:44] [SSH] Authentication failed.
Authentication failed.
[08/27/20 20:20:44] Launch failed - cleaning up connection
[08/27/20 20:20:44] [SSH] Connection closed.
credentialsId='3722a835-e9b3-4030-a13f-d5911bef2524' means SSH (through JSch, java library for SSH2 access) will used a specific credential.
That credential can be a password, or a SSH key.
But in any case, it does not seems to be the right credential.

Jenkins slave configuration issue in linux

I am facing the below issue please have a look. Thanks in advance.
Searching for lokesh in /var/lib/jenkins/.ssh/known_hosts
Searching for lokesh:22 in /var/lib/jenkins/.ssh/known_hosts
[06/04/20 12:59:45] [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 8 more retries left.
You should add the ssh key (created on the slave) to your known hosts file of in the master (Jenkins user). Follow this link
Also you can try one more thing if this does not work. There is an option of Host key verification strategy in jenkins node setup.
Select Non verifying verification strategy and check.
Let me know if this helps.
run this on your Jenkins server:
ssh-keyscan -H ${IP-OF-AGENT} > ~/.ssh/known_hosts

Jenkins upgrade to 2.58 can't launch slaves

I have upgraded Jenkins from 2.55 to 2.58 and the upgrade appears to have taken all our slaves offline.
Jenkins and slaves all running on linux (RHEL 6)
I've read quite a bit about similar issues but nothing that is 100% the same.
Has anyone run into this before? I've been doing some reading on MACs in sshd_config but haven't had any success getting the slaves restarted.
Any ideas for solution greatly appreciated as I'm probably going to have to shout cake unless I get it sorted by the morning :D
Cheers,
Deon.
Slave log follows -
[05/03/17 19:55:25] [SSH] Opening SSH connection to . Key
exchange was not finished, connection is closed. java.io.IOException:
There was a problem while connecting to at
com.trilead.ssh2.Connection.connect(Connection.java:834) at
com.trilead.ssh2.Connection.connect(Connection.java:703) at
com.trilead.ssh2.Connection.connect(Connection.java:617) at
hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1265)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:790)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:785)
at java.util.concurrent.FutureTask.run(FutureTask.java:266) at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745) Caused by:
java.io.IOException: Key exchange was not finished, connection is
closed. at
com.trilead.ssh2.transport.KexManager.getOrWaitForConnectionInfo(KexManager.java:95)
at
com.trilead.ssh2.transport.TransportManager.getConnectionInfo(TransportManager.java:237)
at com.trilead.ssh2.Connection.connect(Connection.java:786) ... 9
more Caused by: java.io.IOException: Cannot read full block, EOF
reached. at
com.trilead.ssh2.crypto.cipher.CipherInputStream.getBlock(CipherInputStream.java:81)
at
com.trilead.ssh2.crypto.cipher.CipherInputStream.read(CipherInputStream.java:108)
at
com.trilead.ssh2.transport.TransportConnection.receiveMessage(TransportConnection.java:232)
at
com.trilead.ssh2.transport.TransportManager.receiveLoop(TransportManager.java:706)
at
com.trilead.ssh2.transport.TransportManager$1.run(TransportManager.java:502)
... 1 more [05/03/17 19:55:25] Launch failed - cleaning up connection
[05/03/17 19:55:25] [SSH] Connection closed.

Unable to create a windows salve node for jenkins

I have setup a master on Ubuntu machine and want to create a salve on Windows 10. While launching the agent I am facing following issue. Can someone please help.
just before slave javed_pc gets launched ...
executing pre-launch scripts ...
[2017-04-21 10:26:54] [windows-slaves] Connecting to 172.26.152.23
Checking if Java exists
java -version returned 1.8.0.
[2017-04-21 10:26:56] [windows-slaves] Copying jenkins-slave.xml
[2017-04-21 10:26:56] [windows-slaves] Copying slave.jar
[2017-04-21 10:26:56] [windows-slaves] Starting the service
ERROR: Unexpected error in launching an agent. This is probably a bug in Jenkins
org.jinterop.dcom.common.JIException: Service Logon Failure
at org.jvnet.hudson.wmi.Win32Service$Implementation.start(Win32Service.java:149)
Caused: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor206.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.kohsuke.jinterop.JInteropInvocationHandler.invoke(JInteropInvocationHandler.java:140)
Caused: java.lang.reflect.UndeclaredThrowableException
at com.sun.proxy.$Proxy64.start(Unknown Source)
at hudson.os.windows.ManagedWindowsServiceLauncher.launch(ManagedWindowsServiceLauncher.java:342)
at hudson.slaves.SlaveComputer$1.call(SlaveComputer.java:262)
at jenkins.util.ContextResettingExecutorService$2.call(ContextResettingExecutorService.java:46)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Using the JENKINS Windows Slaves Plugin, check if one of the reason listed in "Windows slaves fail to start via DCOM" would apply in your case.
It lists a wide variety of reasons, from the Windows account used, to network, registry, security reasons.
Make sure you don't have a proxy issue, where Jenkins would try and use said proxy to access a machine (Windows here) on your LAN: the environment variable no_proxy should be used to exclude your local domain.
The OP Javed Ahmed reports having solve it with:
In 'Configure Global security' settings, when you check 'Enable Security' option, then it allows you to connect via java web start.
Otherwise It was not showing the the option to connect through java web start and connecting via windows service is a pain.

Unable to start SLAVE node in Jenkins

Unable to start SLAVE node in Jenkins.
Master machine showing error exception in log file.
[12/01/14 16:21:44] [SSH] Opening SSH connection to
10.0.11.120:22.
Connection refused: connect
ERROR: Unexpected error in launching a slave. This is probably a bug in Jenkins.
java.lang.IllegalStateException: Connection is not established!
at com.trilead.ssh2.Connection.getRemainingAuthMethods(Connection.java:1030)
at com.cloudbees.jenkins.plugins.sshcredentials.impl.TrileadSSHPasswordAuthenticator.canAuthenticate(TrileadSSHPasswordAuthenticator.java:82)
at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:207)
at com.cloudbees.jenkins.plugins.sshcredentials.SSHAuthenticator.newInstance(SSHAuthenticator.java:169)
at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1173)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:701)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:696)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
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)
[12/01/14 16:21:45] Launch failed - cleaning up connection
[12/01/14 16:21:45] [SSH] Connection closed.
[12/01/14 16:23:44] [SSH] Opening SSH connection to 10.0.11.120:22.
If your slave machine is Mac then
Go to System Preferences -> Sharing and enable Remote Login then try again.
I had this problem too. I have trace the log of the slave.
tail -f /var/log/*.log
And I have seen this message.
Sep 20 14:51:43 clicrdv.aws-eu-west-01.batch-01.adm sshd[1035]: fatal: no matching mac found: client hmac-sha1-96,hmac-sha1,hmac-md5-96,hmac-md5 server hmac-sha2-512,hmac-sha2-256,hmac-ripemd160 [preauth]
Then, I have deleted this line in /etc/ssh/sshd_config
#MACs hmac-sha2-512,hmac-sha2-256,hmac-ripemd160
And restart ssh.
Then no problem at all.
Eric
I suspect that you need to install the Java Cryptography Extension for your JVM. Without that the RSA key size is limited and authentication is not being established.
See https://issues.jenkins-ci.org/browse/JENKINS-26495 for more details.
I had this problem and resolved it by replacing the IP address with the host name.
Problem was solved for my by replacing host name by IP Adress.
See also: https://issues.jenkins-ci.org/browse/JENKINS-26379?focusedCommentId=249378&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-249378

Resources