Cannot SSH into Jenkins-cli

When I ssh (I am using Windows 10 with OpenSSH) into jenkins-cli.jar I get the following error:

Jan 05, 2023 12:48:06 PM io.jenkins.cli.shaded.org.apache.sshd.common.util.security.AbstractSecurityProviderRegistrar getOrCreateProvider
INFO: getOrCreateProvider(EdDSA) created instance of io.jenkins.cli.shaded.net.i2p.crypto.eddsa.EdDSASecurityProvider
Jan 05, 2023 12:48:07 PM io.jenkins.cli.shaded.org.apache.sshd.common.io.DefaultIoServiceFactoryFactory getIoServiceProvider
INFO: No detected/configured IoServiceFactoryFactory; using Nio2ServiceFactoryFactory
io.jenkins.cli.shaded.org.apache.sshd.common.RuntimeSshException: Failed to get the session.
        at io.jenkins.cli.shaded.org.apache.sshd.client.future.DefaultConnectFuture.getSession(DefaultConnectFuture.java:59)
        at io.jenkins.cli.shaded.org.apache.sshd.client.future.DefaultConnectFuture.getSession(DefaultConnectFuture.java:34)
        at hudson.cli.SSHCLI.sshConnection(SSHCLI.java:102)
        at hudson.cli.CLI._main(CLI.java:294)
        at hudson.cli.CLI.main(CLI.java:103)
Caused by: java.io.IOException: The semaphore timeout period has expired
        at java.base/sun.nio.ch.Iocp.translateErrorToIOException(Iocp.java:299)
        at java.base/sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:389)
        at java.base/java.lang.Thread.run(Thread.java:1589)

After trying:

java -jar jenkins-cli.jar -s SERVER:8080/ -ssh -user MY_USERNAME

What is the cause of this error, so that I can fix it and SSH into my jenkins instance?

Hello @emimri and welcome to this community :wave:

What version of Jenkins are you running?
Your controller is running on Windows, am I right?
What is your Java version?
What is the operating system your Jenkins agent is running?
What is its operating system?

What are you trying to achieve? Link a Jenkins agent from the controller to the agent through ssh ?

Please have a look at Using Jenkins agents .

Hello Bruno,

Not sure whether I can answer all your questions accurately.

I have been granted permission to have access to Jenkins, I believe the controller is someone else in my business. I am using windows 10, but have all access/permissions in Jenkins.

We’re running Jenkins on a server, but I am attempting to ssh into Jenkins following this documentation: Jenkins CLI

I am using Java:

java version "19.0.1" 2022-10-18
Java(TM) SE Runtime Environment (build 19.0.1+10-21)
Java HotSpot(TM) 64-Bit Server VM (build 19.0.1+10-21, mixed mode, sharing)

The operating system is Linux:

os.version: 3.10.0-1160.53.1.el7.x86_64

The Jenkins is using Java 11 version 55.

I was going to attempt to SSH into Jenkins and sudo apt-get install a package with admin permissions, because I cannot do this in the shell. Unless, there is an alternative approach?

1 Like

Is there an HTTP reverse proxy between your machine and the Jenkins controller?
Is there a firewall?
Are the ssh ports authorized?

Well our jenkins server runs on a VPN, and it’s only available as an application on the browser when the VPN is on.

I have attempted the link you have provided with using Jenkins agents. Although, I attempted this on my mac os, which does not have vpn access to our jenkins server. However, my windows PC does, would I still get SSH access to jenkins with this approach?

After some extra research:

  1. My windows environment lacks administration privileges, therefore, this could be blocking the SSH access.
1 Like

I have no idea on what’s blocking the ssh connection, but so that you do not loose to much time to pursue something that won’t work in the end:

I was going to attempt to SSH into Jenkins and sudo apt-get install a package with admin permissions, because I cannot do this in the shell.

This is not what the ssh mode of the Jenkins-cli will bring you. It just use ssh to communicate with Jenkins to run jenkins-cli commands (like trigger a job, get the result of a job etc…) but it won’t open a shell to the machine running Jenkins.

Ah I see! It’s possible I am blocked by a company firewall that prevents the SSH connection from going through successfully.

Additionally, by what other means can I successfully sudo install files, or can this only be granted by the controller who has access to the Jenkins files to modify ROOT access for users?

by what other means can I successfully sudo install files

You need to ask your ops team an access to the machine with proper permissions.

1 Like