docker-vboxwebsrv
docker-vboxwebsrv copied to clipboard
Support SSH keys
I think this is directly related to one of my questions from https://github.com/clue/docker-phpvirtualbox/issues/5 (starting without user intervention). I did a little googling and found this:
RUN mkdir -p /root/.ssh
ADD url_for_id_rsa /root/.ssh/id_rsa
RUN chmod 700 /root/.ssh/id_rsa
RUN echo "Host github.com\n\tStrictHostKeyChecking no\n" >> /root/.ssh/config
I"m not sure that will actually work, but maybe? Since it's common practice to setup a vbox user to run virtualbox with phpvirtualbox, perhaps adapt it to:
RUN mkdir -p /home/vbox/.ssh
ADD url_for_id_rsa /home/vbox/.ssh/id_rsa
RUN chmod 700 /home/vbox/.ssh/id_rsa
RUN echo "Host *\n\tStrictHostKeyChecking no\n" >> /home/vbox/.ssh/config
I did a little playing around to see if I map in the vbox's user's .ssh directory as a volume as a workaround:
su vbox
ssh-keygen
ssh-copy-id localhost
echo "Host *\n\tStrictHostKeyChecking no\n" >> ~/.ssh/config
Then I attempted to startup the container mapping /home/vbox/.ssh to /home/.ssh as a volume:
sudo docker run -it -v /home/vbox/.ssh:/home/.ssh ubuntu:14.04 /bin/bash
And the vbox .ssh directory is present at /home/.ssh:
root@56176f3ae6e1:/# ls -la /home/.ssh
total 28
drwx------ 2 1002 125 4096 May 14 03:21 .
drwxr-xr-x 3 root root 4096 May 14 03:43 ..
-rw------- 1 1002 125 395 May 14 03:20 authorized_keys
-rw-r--r-- 1 1002 125 37 May 14 03:21 config
-rw------- 1 1002 125 1679 May 14 03:15 id_rsa
-rw------- 1 1002 125 395 May 14 03:15 id_rsa.pub
-rw-r--r-- 1 1002 125 222 May 14 03:16 known_hosts
So I shut that down, and started up vboxwebsrv with:
HOSTIP=`ip -4 addr show scope global dev eth0 | grep inet | awk '{print \$2}' | cut -d / -f 1`
sudo docker run -it --name=vboxwebsrv -v /home/vbox/.ssh:/home/.ssh clue/vboxwebsrv vbox@$HOSTIP
... but I'm still getting prompted for a password.
+1
Look at my pullrequest