Answers: <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>
  
Answers: CC BY-SA 4.0
Answers: 2020-06-03T07:44:31.020Z
Answers: 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..?
Answers: tinamou_ed
Answers: CC BY-SA 4.0
Answers: 2020-06-03T07:50:24.070Z
Answers: 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.
Answers: Bruce Becker
Answers: CC BY-SA 4.0
Answers: 2020-06-03T08:26:32.067Z
Answers: 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.
Answers: tinamou_ed
Answers: CC BY-SA 4.0
Answers: 2020-06-03T07:14:56.473Z
Answers: 2020-06-03T07:14:56.473Z
Answers: Bruce Becker
Body: <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>
  
Tags: <docker><jenkins>
Title: How do I setup ssh from jenkinsci/blueocean docker to remote?
UserDisplayName: tinamou_ed
ThreadText: # 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](https://github.com/AAROC/CODE-RADE-container) 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.  
  
  ---
  
  