title: How to configure Debian SSHD for remote debugging in a Docker container?
body: <p>I'm trying to setup remote debugging to a Docker Debian container, to debug a Ruby application on my Windows laptop.</p>
  
  <p>This is the post that lead me in this direction:
  <a href="https://intellij-support.jetbrains.com/hc/en-us/community/posts/207649545-Use-RubyMine-and-Docker-for-development-run-and-debug-before-deployment-for-testing-" rel="nofollow noreferrer">https://intellij-support.jetbrains.com/hc/en-us/community/posts/207649545-Use-RubyMine-and-Docker-for-development-run-and-debug-before-deployment-for-testing-</a></p>
  
  <p>I have the Ruby app and SSHD running in the container, though the recipe I found for configuring SSHD isn't fully compatible with the Linux distro that the Ruby image is based on.</p>
  
  <p>I based my SSHD configuration on this Docker documentation page: <a href="https://docs.docker.com/engine/examples/running_ssh_service/" rel="nofollow noreferrer">https://docs.docker.com/engine/examples/running_ssh_service/</a></p>
  
  <p>My image is based on the ruby:2.2 image from Docker Hub, which uses Debian 8 as opposed to Ubuntu 16.04 used in the SSHD example above.</p>
  
  <p>I can get to a SSH prompt but I can't login with the screencast password for root that's set in the dockerfile.</p>
  
  <p>I'm open to whatever solution works, either properly enabling root login or adding a new user with the correct permissions to allow for remote debugging. I'm just curious which path would be most straight forward in the Debian context. And if it's creating a new user, what permissions do they need?</p>
  
  <p>Also, to be clear I'm treating this as a trial run and will obviously make sure to strip out the SSHD functionality in some way when I go to deploy the app for any context outside of development.</p>
  
  <p>Thanks in advance for your help.</p>
  
  <p>This is my current dockerfile</p>
  
  <pre><code>FROM ruby:2.2
  RUN apt-get update &amp;&amp; apt-get install -y \
      build-essential \
      libpq-dev \
      nodejs \
      openssh-server
  
  RUN mkdir /var/run/sshd
  RUN echo 'root:screencast' | chpasswd
  RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
  
  # SSH login fix. Otherwise user is kicked off after login
  RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
  
  ENV NOTVISIBLE "in users profile"
  RUN echo "export VISIBLE=now" &gt;&gt; /etc/profile
  
  RUN mkdir /MyApp
  WORKDIR /MyApp
  ADD Gemfile /MyApp/Gemfile
  ADD Gemfile.lock /MyApp/Gemfile.lock
  RUN bundle install
  ADD . /MyApp
  </code></pre>
  
  <p>and this is my docker-compose.yml</p>
  
  <pre><code>version: '2'
  services:
    web:
      build: .
      command: /CivilService/docker-dev-start.sh
      volumes:
        - .:/CivilService
      ports:
        - "3000:3000"
        - "3022:22"
  </code></pre>
  
  <p>The docker-dev-start.sh looks like this</p>
  
  <pre><code>#!/bin/bash
  
  # start the SSH server for connecting the debugger in development
  /usr/sbin/sshd -D &amp;
  bundle exec rails s -p 3000 -b '0.0.0.0'
  </code></pre>