Last active
May 1, 2024 12:51
-
-
Save udkyo/c20935c7577c71d634f0090ef6fa8393 to your computer and use it in GitHub Desktop.
Basic container for X11 forwarding goodness
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 ubuntu | |
RUN apt update \ | |
&& apt install -y firefox \ | |
openssh-server \ | |
xauth \ | |
&& mkdir /var/run/sshd \ | |
&& mkdir /root/.ssh \ | |
&& chmod 700 /root/.ssh \ | |
&& ssh-keygen -A \ | |
&& sed -i "s/^.*PasswordAuthentication.*$/PasswordAuthentication no/" /etc/ssh/sshd_config \ | |
&& sed -i "s/^.*X11Forwarding.*$/X11Forwarding yes/" /etc/ssh/sshd_config \ | |
&& sed -i "s/^.*X11UseLocalhost.*$/X11UseLocalhost no/" /etc/ssh/sshd_config \ | |
&& grep "^X11UseLocalhost" /etc/ssh/sshd_config || echo "X11UseLocalhost no" >> /etc/ssh/sshd_ | |
config | |
RUN echo "YOUR_PUB_KEY_HERE" >> /root/.ssh/authorized_keys | |
ENTRYPOINT ["sh", "-c", "/usr/sbin/sshd && tail -f /dev/null"] |
Very helpful stuff here but the the content has traveled some since the initial post. Steps I used:
- @AutomationMusician's April 2018 post with the password file trick
- @peter279k's suggestion to use
FROM ubuntu:18.04
(edit: just tried again with 22.04 and it was fine) and his other steps on July 16, 2021. If you ssh in without filrefox on the end you can just type it at the terminal
Note that if you're working in a text editor that automatically adds a newline, like vim, don't add a blank line as it will do that for you (and the blank line will break it).
Might come back for the ssh keys-based method later.
I'm on MacOS and it's interesting to me that nowhere was the DISPLAY environment variable mentioned, or volume informations specified (e.g., '-v /tmp/.X11-unix:/tmp/.X11-unix'). These were huge red herrings in my attempts to figure this out.
Thanks. It also works for foreign architecture.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh I have managed to get past the password part, appears I didn't add the UNIX newline character, thank you so much for you help!