# Cannot SSH into Jenkins-cli

**URL:** https://community.jenkins.io/t/cannot-ssh-into-jenkins-cli/5222
**Category:** Ask a question
**Created:** [January 5, 2023, 1:02pm UTC](https://community.jenkins.io/t/cannot-ssh-into-jenkins-cli/5222 "2023-01-05T13:02:10Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![emimri](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@emimri](https://community.jenkins.io/u/emimri)
#### Post date: [January 5, 2023, 1:02pm UTC](https://community.jenkins.io/t/cannot-ssh-into-jenkins-cli/5222/1 "2023-01-05T13:02:10Z")

</div>

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

```auto
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:

```auto
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?

---

<div class="post-metadata">

### Author: ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)
#### Post date: [January 5, 2023, 1:34pm UTC](https://community.jenkins.io/t/cannot-ssh-into-jenkins-cli/5222/2 "2023-01-05T13:34:51Z")

</div>

Hello @emimri and welcome to this community 👋

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](https://www.jenkins.io/doc/book/using/using-agents/) .

---

<div class="post-metadata">

### Author: ![emimri](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@emimri](https://community.jenkins.io/u/emimri)
#### Post date: [January 5, 2023, 1:45pm UTC](https://community.jenkins.io/t/cannot-ssh-into-jenkins-cli/5222/3 "2023-01-05T13:45:01Z")

</div>

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](https://www.jenkins.io/doc/book/managing/cli/)

I am using Java:

```auto
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:

```auto
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?

---

<div class="post-metadata">

### Author: ![poddingue](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/poddingue/32/985_2.png) [@poddingue](https://community.jenkins.io/u/poddingue)
#### Post date: [January 5, 2023, 2:12pm UTC](https://community.jenkins.io/t/cannot-ssh-into-jenkins-cli/5222/4 "2023-01-05T14:12:31Z")

</div>

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

---

<div class="post-metadata">

### Author: ![emimri](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@emimri](https://community.jenkins.io/u/emimri)
#### Post date: [January 5, 2023, 3:55pm UTC](https://community.jenkins.io/t/cannot-ssh-into-jenkins-cli/5222/5 "2023-01-05T15:55:34Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![PierreBtz](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/pierrebtz/32/55_2.png) [@PierreBtz](https://community.jenkins.io/u/PierreBtz)
#### Post date: [January 6, 2023, 10:03am UTC](https://community.jenkins.io/t/cannot-ssh-into-jenkins-cli/5222/6 "2023-01-06T10:03:22Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![emimri](https://avatars.discourse-cdn.com/v4/letter/e/8baadc/32.png) [@emimri](https://community.jenkins.io/u/emimri)
#### Post date: [January 6, 2023, 2:37pm UTC](https://community.jenkins.io/t/cannot-ssh-into-jenkins-cli/5222/7 "2023-01-06T14:37:27Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![PierreBtz](https://dub1.discourse-cdn.com/flex013/user_avatar/community.jenkins.io/pierrebtz/32/55_2.png) [@PierreBtz](https://community.jenkins.io/u/PierreBtz)
#### Post date: [January 6, 2023, 2:50pm UTC](https://community.jenkins.io/t/cannot-ssh-into-jenkins-cli/5222/8 "2023-01-06T14:50:12Z")

</div>

> 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.
