Created
August 5, 2016 16:13
-
-
Save benlast/b95d568ff61cc4c0b88de35e7aafe931 to your computer and use it in GitHub Desktop.
SSH image support for PyCharm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Put a docker build command here to build your main image | |
# Generate or re-use SSH keys. The ssh_keys directory should | |
# be in .gitignore | |
mkdir -p ssh_keys | |
if [ ! -f ssh_keys/docker-sshd ] ; then | |
echo "Generating SSH key" | |
# Remove any associated public key also | |
rm -f ssh_keys/docker-sshd* | |
ssh-keygen -t rsa -f ssh_keys/docker-sshd -N "" | |
else | |
echo "Using existing SSH key" | |
fi | |
# Now build the sshd server image, which should be based on | |
# the main image. | |
docker build --force-rm=true -f docker/Dockerfile \ | |
--build-arg AUTH_KEY="$(cat ssh_keys/pusheen-sshd.pub)" \ | |
--tag your-tag-here . | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM your-main-image | |
COPY docker/files/sshd_config docker/files/ssh-install.sh /root/ | |
# SSHD key | |
ARG AUTH_KEY | |
RUN /root/ssh-install.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Setup OpenSSHd | |
echo "Configuring OpenSSH" | |
mkdir -p /root/.ssh | |
chmod 700 /root/.ssh | |
echo "${AUTH_KEY}" > /root/.ssh/authorized_keys | |
chmod 600 /root/.ssh/* | |
chown -Rf root:root /root/.ssh | |
mkdir -p /var/run/sshd | |
mkdir -p /etc/ssh | |
mv /root/sshd_config /etc/ssh/sshd_config | |
apt-get -y install openssh-server | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Set this to some port that your setup doesn't use | |
Port 5022 | |
ListenAddress 0.0.0.0 | |
Protocol 2 | |
PermitRootLogin without-password | |
RSAAuthentication yes | |
PubkeyAuthentication yes | |
#AuthorizedKeysFile %h/.ssh/authorized_keys | |
Subsystem sftp internal-sftp | |
UsePAM yes | |
AllowTcpForwarding yes | |
# Fix for PyCharm remote debugger support | |
KexAlgorithms=diffie-hellman-group1-sha1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What command do you use to run the docker container? I tried /usr/sbin/sshd but auth doesn't seem to be working.