Jenkins Master-Slave: Key exchange was not finished, connection is closed - jenkins

I want to connect a slave to Master-Jenkins, but when trying to connect i'm getting following Error:
[05/02/18 15:26:59] [SSH] Opening SSH connection to <IP>
Key exchange was not finished, connection is closed.
java.io.IOException: There was a problem while connecting to <IP>:22
at com.trilead.ssh2.Connection.connect(Connection.java:818)
at hudson.plugins.sshslaves.SSHLauncher.openConnection(SSHLauncher.java:1324)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:831)
at hudson.plugins.sshslaves.SSHLauncher$2.call(SSHLauncher.java:820)
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:748)
Caused by: java.io.IOException: Key exchange was not finished, connection is closed.
at com.trilead.ssh2.transport.KexManager.getOrWaitForConnectionInfo(KexManager.java:93)
at com.trilead.ssh2.transport.TransportManager.getConnectionInfo(TransportManager.java:230)
at com.trilead.ssh2.Connection.connect(Connection.java:770)
... 7 more
Caused by: java.io.IOException: Cannot negotiate, proposals do not match.
at com.trilead.ssh2.transport.KexManager.handleMessage(KexManager.java:405)
at com.trilead.ssh2.transport.TransportManager.receiveLoop(TransportManager.java:777)
at com.trilead.ssh2.transport.TransportManager$1.run(TransportManager.java:489)
... 1 more
[05/02/18 15:26:59] Launch failed - cleaning up connection
[05/02/18 15:26:59] [SSH] Connection closed.
Configuration for Node:
- Start-Method: Start Slave over SSH
- Hostname: is the IP
- Access Data: user i created for SSH Access - > public key is in authorized keys on Slave Node
If i am on my Master as user "jenkins" and do a ssh jenkins#<IP> i can login wihtout problems (public key is on slave).
Why it doesn't work for "UI-Jenkins".
Jenkins-Version: 1.658
Node: Ubuntu 14.04
SSH-Slave Plugin: 1.26

That "solved" the issue:
"Workaround is by commenting out MACs and KexAlgorithm line in /etc/ssh/sshd_config of Jenkins Slave and restarting the sshd (service ssh restart on Ubuntu)
UPDATE: the issue has been resolved as of 2017-04-29 "
Jenkins master fails to connect to the slave over SSH

Thought I'd throw my experience in this thread: my environment had a Windows master and mixed Windows and Linux agents. One Windows agent refused to connect to master, even after Master pushed 'jenkins-agent' and the other supporting files to the agent.
This agent had 6 different versions of the JDK and JRE installed. I uninstalled all of them, reinstalled only the latest JDK we needed, and set JAVA_HOME. This fixed the connectivity issue.

Execute this command on destination node.
sudo -i su -c 'sed -i -e "s/MACs /MACs hmac-sha1,/g" /etc/ssh/sshd_config; service sshd restart'

Just recently run into this issue with docker
Find the Java Path
/home/jenkins # which java
/opt/java/openjdk/bin/java
Export the Java Path. In this case I am using the docker-compose
...
exp_agent:
image: jenkins/ssh-agent:alpine
restart: always
environment:
JENKINS_AGENT_SSH_PUBKEY: $ENV_JENKINS_AGENT_SSH_PUBKEY
JAVA_HOME: $ENV_JAVA_HOME
container_name: jenkins-ssh-agent
ports:
- 22:22
networks:
- jenkins
...
The master still complains about the path of Java as /opt/java/openjdk/bin/java is not among the expected paths
...
[12/04/21 11:44:07] [SSH] Checking java version of /usr/bin/java
...
Create a symbolic link between the java path and one of the expected paths in the docker container (This could be automated in a Dockerfile)
ln -s /opt/java/openjdk/bin/java /usr/bin/java

Related

Running a Chainlink Node - Can't connect to database

Using docker-desktop on macOS.
I'm trying to run a node following the instructions on this page.
The database name is node, which is the same as the username: node. The user has access to the database and can log in using psql client.
Connection strings I've tried in the .env file:
postgresql://node#localhost/node
postgresql://node:password#localhost/node
postgresql://node:password#localhost:5432/node
postgresql://node:password#127.0.0.1:5432/node
postgresql://node:password#127.0.0.1/node
When I run the start command: cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink local n , using docker-desktop on macOS, I get the following stack trace:
2020-09-15T14:24:41Z [INFO] Starting Chainlink Node 0.8.15 at commit a904730bd62c7174b80a2c4ccf885de3e78e3971 cmd/local_client.go:50
2020-09-15T14:24:41Z [INFO] SGX enclave *NOT* loaded cmd/enclave.go:11
2020-09-15T14:24:41Z [INFO] This version of chainlink was not built with support for SGX tasks cmd/enclave.go:12
2020-09-15T14:24:41Z [INFO] Locking postgres for exclusive access with 500ms timeout orm/orm.go:69
2020-09-15T14:24:41Z [ERROR] unable to lock ORM: dial tcp 127.0.0.1:5432: connect: connection refused logger/default.go:139 stacktrace=github.com/smartcontractkit/chainlink/core/logger.Error
/chainlink/core/logger/default.go:117
...
Does anyone know how I can resolve this?
The problem probably caused by the fact that your chainlink database has been locked with Exclusive Lock and before stopping node that locks never removed.
What you do in this situation (as what works for me) is use PgAdmin Ui or similar way to find all Locks then find the Exclusive Lock that is held on the chainlink database and note down its Process id or ids (if multiple exclusive locks there are on chainlink DB)
Log in to your pg client and run SELECT pg_terminate_backend(<pid>) or SELECT pg_cancel_backend(<pid>); Enter PID of those locks here without quotes and meanwhile keep refreshing on pg admin URL to see if those processes stopped If stopped then rerun your chainlink node.
The problem is with docker networking.
Add --network host to the docker run command so that it is:
cd ~/.chainlink-kovan && docker run -p 6688:6688 -v ~/.chainlink-kovan:/chainlink -it --env-file=.env smartcontract/chainlink --network host local n
This fixes the issue.

docker-machine create keeps asking for password

I am attempting to docker-machine create to a Ubuntu 16.04 host like this:
ssh-keygen -R ${remote_host}
ssh-copy-id -i ~/.ssh/id_host_rsa.pub root#${remote_host}
docker-machine create \
--driver generic \
--generic-ip-address=${remote_host} \
--generic-ssh-key ~/.ssh/id_host_rsa \
--generic-ssh-user=root ${machine_name}
Version information:
docker --version
Docker version 19.03.6, build 369ce74a3c
docker-machine --version
docker-machine version 0.16.2, build bd45ab13
I am repeatedly asked for a password .. Why is this?
Here is the output:
...
Are you sure you want to continue connecting (yes/no)? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: ERROR: Received disconnect from 77.68.21.66 port 22:2: Too many authentication failures
ERROR: Disconnected from 77.68.21.66 port 22
Running pre-create checks...
Creating machine...
(production) Importing SSH key...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Password:
Detecting the provisioner...
Password:
Provisioning with ubuntu(systemd)...
Password:
.. etc
The reason for this problem was the ordering of ~/.ssh/config.
I had a Host * entry in config first, before that of my corresponding specific server Host XX.XX.XX.XX entry.
I moved the wildcard entry at the end of ~/.ssh/config and now the password is no longer constantly asked for and the problem is now fixed.
I how this helps someone.

startNodeManager.sh not found

I have been trying to run Oracle weblogic in Docker containers and i am facing trouble in starting the NodeManager.I ran the following command.
docker run -d --name MS1 --link wlsadmin:wlsadmin -p 8001:8001 -e ADMIN_PASSWORD=#123 \
-e MS_NAME=MS1 --volumes-from wlsadmin a5e55 createServer.sh
Under normal circumstances it is expected to start the Nodemanager.
I am able to access the weblogic console and start the Managed Server which then returns the error-
-- Warning For server MS1, the Node Manager associated with machine Machine_MS1 is not reachable
This is the part of the log file that is returned on executing the above "docker run" command :
Domain Home: /u01/oracle/user_projects/domains/base_domain
Managed Server Name: MS1
NodeManager Name:
----> 'weblogic' admin password: ctebs#123
Waiting for WebLogic Admin Server on wlsadmin:7001 to become available...
WebLogic Admin Server is now available. Proceeding...
Setting NodeManager
----> No NodeManager Name set
Node Manager Name: Machine_MS1
Node Manager Home for Container: /u01/oracle/user_projects/domains/base_domain/Machine_MS1
cp: cannot stat '/u01/oracle/user_projects/domains/base_domain /bin/startNodeManager.sh': No such file or directory
cp: cannot stat '/u01/oracle/user_projects/domains/base_domain/nodemanager/*': No such file or directory
NODEMGR_HOME_STR: NODEMGR_HOME="/u01/oracle/user_projects/domains/base_domain/Machine_MS1"
NODEMGRHOME_STR: NodeManagerHome=/u01/oracle/user_projects/domains/base_domain/Machine_MS1
DOMAINSFILE_STR: DomainsFile=/u01/oracle/user_projects/domains/base_domain/Machine_MS1/nodemanager.domains
LOGFILE_STR: LogFile=/u01/oracle/user_projects/domains/base_domain/Machine_MS1/nodemanager.log
sed: can't read /u01/oracle/user_projects/domains/base_domain/Machine_MS1/startNodeManager.sh: No such file or directory
sed: can't read /u01/oracle/user_projects/domains/base_domain/Machine_MS1/nodemanager.properties: No such file or directory
sed: can't read /u01/oracle/user_projects/domains/base_domain/Machine_MS1/nodemanager.properties: No such file or directory
sed: can't read /u01/oracle/user_projects/domains/base_domain/Machine_MS1/nodemanager.properties: No such file or directory
Starting NodeManager in background...
NodeManager started.
Connection refused (Connection refused). Could not connect to NodeManager. Check that it is running at /172.17.0.3:5556.
Starting server MS1 ...No stack trace available.
This Exception occurred at Tue Dec 12 03:38:06 GMT 2017.
weblogic.management.scripting.ScriptException: Error occurred while performing start : Server with name MS1 failed to be started
No stack trace available.
How can I get past this error message?
You can try and follow this OracleWebLogic workshop intro which points out:
The ~/docker-images/OracleWebLogic/samples/1221-domain/container-scripts has useful Bash and WLST scripts that provide three possible modes to run WebLogic Managed Servers on a Docker container. Make sure you have an AdminServer container running before starting a ManagedServer container.
The sample scripts will by default, attempt to find the AdminServer running at t3://wlsadmin:8001. You can change this.
But most importantly, the AdminServer container has to be linked with Docker's --link parameter.
Below, are the three suggestions for running ManagedServer Container within the sample 12c-domain:
Start NodeManager (Manually):
docker run -d --link wlsadmin:wlsadmin startNodeManager.sh
Start NodeManager and Create a Machine Automatically:
docker run -d --link wlsadmin:wlsadmin createMachine.sh
Start NodeManager, Create a Machine, and Create a ManagedServer Automatically
docker run -d --link wlsadmin:wlsadmin createServer.sh
See more at "Example of Image with WLS Domain", removed in commit e49bb4d in Apr. 2019, 2 yers later, since Oracle no longer supports WebLogic versions.

Docker: Jenkins container can't access internet on QNAP device

I try to get the Docker image (1.651.3 or latest version) running on my QNAP NAS using the internal ContainerStation.
Just using the default settings without setting any parameters or binding any resource, I can't access the internet. I already tried the NAT or Host network mode, but this would make no difference.
Stacktrace:
Oct 02, 2016 1:55:07 PM javax.jmdns.impl.HostInfo newHostInfo
WARNING: Could not intialize the host network interface on nullbecause of an error: 5929616b9f0b: 5929616b9f0b: unknown error
java.net.UnknownHostException: 5929616b9f0b: 5929616b9f0b: unknown error
at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
at javax.jmdns.impl.HostInfo.newHostInfo(HostInfo.java:75)
at javax.jmdns.impl.JmDNSImpl.<init>(JmDNSImpl.java:407)
at javax.jmdns.JmDNS.create(JmDNS.java:60)
at hudson.DNSMultiCast$1.call(DNSMultiCast.java:32)
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)
Caused by: java.net.UnknownHostException: 5929616b9f0b: unknown error
at java.net.Inet4AddressImpl.lookupAllHostAddr(Native Method)
at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
at java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
at java.net.InetAddress.getLocalHost(InetAddress.java:1500)
... 9 more
Using bash:
$ ping google.de
ping: unknown host
Any idea what might be the problem? Any other docker image can access the internet, only this image has these problems.
I recently experienced the same problem and in my case it turned out to be caused by the ACL lists on the QNAP, preventing the jenkins user in the container from reading the /etc/hosts and /etc/resolv.conf files.
Here's how I fixed it. Perhaps it can be of some help to you as well:
ssh to the QNAP
$ ssh admin#<your IP or domain name here>
Manually create a jenkins user on the QNAP with UID 1000 (the same
UID as the jenkins user in the container)
$ useradd -u 1000 -M -s /bin/false jenkins
Log into the QNAP web interface
Navigate to Control panel -> Users
Click the Edit Shared Folder Permissions icon for the jenkins user
Tick the RW checkbox (Read/Write access) for the Container folder
and click Apply
Start your Jenkins container
Disclaimer: I am no sysadmin so I don't know whether this approach would cause any security issues on your system. You may want to look into that before giving outside access to your Jenkins web interface... :)

Configure Jenkins Mac OS X native package to run in a different port

Jenkins native Mac OS package installs by default in /Users/Shared/Jenkins and the war in /Applications/Jenkins. It runs as a daemon and restarts automatically in spite of a kill -9 command.
I added a winstone.properties in /Applications/Jenkins with a single prop, httpPort=9999.
Still app starts on 8080.
I even installed CLI and tried:
java -jar jenkins-cli.jar -s http://127.0.0.1:8080/ shutdown
Failed to authenticate with your SSH keys. Proceeding with anonymous access
Sep 19, 2011 1:11:00 PM hudson.remoting.Channel$ReaderThread run
SEVERE: I/O error in channel CLI connection to http://127.0.0.1:8080/
java.io.IOException: Unexpected termination of the channel
at hudson.remoting.Channel$ReaderThread.run(Channel.java:1093)
Caused by: java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2553)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at hudson.remoting.Channel$ReaderThread.run(Channel.java:1087)
Exception in thread "main" hudson.remoting.RequestAbortedException: hudson.remoting.RequestAbortedException: java.io.IOException: Unexpected termination of the
channel
at hudson.remoting.Request.call(Request.java:149)
at hudson.remoting.Channel.call(Channel.java:681)
at hudson.remoting.RemoteInvocationHandler.invoke(RemoteInvocationHandler.java:158)
at $Proxy2.main(Unknown Source)
at hudson.cli.CLI.execute(CLI.java:171)
at hudson.cli.CLI._main(CLI.java:297)
at hudson.cli.CLI.main(CLI.java:216)
Caused by: hudson.remoting.RequestAbortedException: java.io.IOException: Unexpected termination of the channel
at hudson.remoting.Request.abort(Request.java:273)
at hudson.remoting.Channel.terminate(Channel.java:732)
at hudson.remoting.Channel$ReaderThread.run(Channel.java:1117)
Caused by: java.io.IOException: Unexpected termination of the channel
at hudson.remoting.Channel$ReaderThread.run(Channel.java:1093)
Caused by: java.io.EOFException
at java.io.ObjectInputStream$BlockDataInputStream.peekByte(ObjectInputStream.java:2553)
at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1296)
at java.io.ObjectInputStream.readObject(ObjectInputStream.java:350)
at hudson.remoting.Channel$ReaderThread.run(Channel.java:1087)
In short, I can't force stop/start Jenkins and/or configure (I can via manual procedure, using a war though).
Suggestions?
Any idea how to configure the Jenkins
Try:
sudo defaults write /Library/Preferences/org.jenkins-ci httpPort '9999'
To check that it has worked use:
defaults read /Library/Preferences/org.jenkins-ci
Then kill the Jenkins process and let it restart.
You want to use launchctl to start and stop Jenkins. From the example at luscarpa.com: Start & Stop Jenkins daemon on Mac OS X:
Start Jenkins:
sudo launchctl load /Library/LaunchDaemons/org.jenkins-ci.plist
Stop Jenkins:
sudo launchctl unload /Library/LaunchDaemons/org.jenkins-ci.plist
For those new to killing processes (like I am):
$ ps -e | grep jenkins
53 ?? 0:02.51 /usr/bin/java -jar /Applications/Jenkins/jenkins.war
392 ttys000 0:00.00 grep jenkins
$ sudo kill 53

Resources