<p>You can run an ssh server in the container as the <code>ENTRYPOINT</code>. It can either be started in the foreground : </p>

<pre><code>ENTRYPOINT ["/usr/sbin/sshd", "-D","-p","22"]
</code></pre>

<p>Ensure that you have <code>openssh</code> installed and host keys setup.</p>

<p>Perhaps <a href="https://github.com/AAROC/CODE-RADE-container" rel="nofollow noreferrer">this Ansible role</a> would be illustrative</p>

CC BY-SA 4.0
2020-06-03T07:44:31.020Z
Thanks. Ansible is next in the learning cycle...I get what you're saying about the ENTRYPOINT. I can try that it just seems strange that this official image doesn't come with this on. As I said I'm new to Jenkins but isn't using ssh from Jenkins the sort of thing one would do from the outset. Even with what you said there is no way to create directories for the SSH keys without being able to use sudo and I'm not sure I can install sudo as the Jenkins user. All this makes me think 'this is how it works' and I'm approaching it the wrong way. Maybe install sudo as well via the ENTRYPOINT..?
tinamou_ed
CC BY-SA 4.0
2020-06-03T07:50:24.070Z
Access to the container via SSH is not what jenkins agent is designed to do - rather, it is designed to use the JNLP connection. If you _really_ want to you can set up the ssh connection, but it requires extra work.
Bruce Becker
CC BY-SA 4.0
2020-06-03T08:26:32.067Z
I don't want to access the container with ssh I want to use ssh on the Jenkins docker to connect to a remote server to 'do something'. Is that not how Jenkins authenticates commonly to slaves? It seems strange this is taught on Linux academy in 'jenkins for beginners' if master and slave don't commonly use ssh.
tinamou_ed
CC BY-SA 4.0
2020-06-03T07:14:56.473Z
2020-06-03T07:14:56.473Z
Bruce Becker
<p>I am running <code>jenkinsci/blueocean</code> docker locally as per the instructions of running jenkins using a docker on jenkins.io. Everything seems to be working correctly but when I docker exec into the docker, I can't use sudo and I cant create a home directory for the jenkins user with an .ssh directory.</p>

<p>There seems to be apk package manager but if this functionality is not out of the box it makes me wonder if I am doing this wrong.</p>

<p>Does anyone have any experience setting up a basic ssh config on this docker image? </p>

<docker><jenkins>
How do I setup ssh from jenkinsci/blueocean docker to remote?
tinamou_ed
# How do I setup ssh from jenkinsci/blueocean docker to remote?

(Asked by: username_0 on 2020-06-03)

I am running `jenkinsci/blueocean` docker locally as per the instructions of running jenkins using a docker on jenkins.io. Everything seems to be working correctly but when I docker exec into the docker, I can't use sudo and I cant create a home directory for the jenkins user with an .ssh directory.

There seems to be apk package manager but if this functionality is not out of the box it makes me wonder if I am doing this wrong.

Does anyone have any experience setting up a basic ssh config on this docker image?

**Tags:** docker, jenkins


---

## 1 answers

### Answer by username_1 on 2020-06-03. Score: 1

You can run an ssh server in the container as the ENTRYPOINT. It can either be started in the foreground : 
ENTRYPOINT ["/usr/sbin/sshd", "-D","-p","22"]

Ensure that you have openssh installed and host keys setup.
Perhaps this Ansible role would be illustrative

> **Comments:**
> **username_0**: Thanks. Ansible is next in the learning cycle...I get what you're saying about the ENTRYPOINT. I can try that it just seems strange that this official image doesn't come with this on. As I said I'm new to Jenkins but isn't using ssh from Jenkins the sort of thing one would do from the outset. Even with what you said there is no way to create directories for the SSH keys without being able to use sudo and I'm not sure I can install sudo as the Jenkins user. All this makes me think 'this is how it works' and I'm approaching it the wrong way. Maybe install sudo as well via the ENTRYPOINT..?  
> **username_1**: Access to the container via SSH is not what jenkins agent is designed to do - rather, it is designed to use the JNLP connection. If you _really_ want to you can set up the ssh connection, but it requires extra work.  
> **username_0**: I don't want to access the container with ssh I want to use ssh on the Jenkins docker to connect to a remote server to 'do something'. Is that not how Jenkins authenticates commonly to slaves? It seems strange this is taught on Linux academy in 'jenkins for beginners' if master and slave don't commonly use ssh.  

---

