├── LICENSE ├── README.md ├── docker ├── 999-sudoers-docker ├── Dockerfile └── start-sshd.sh └── run.sh /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Tatsuya Kawano 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # docker-x2go 2 | 3 | Remote desktop [X2Go Server](http://wiki.x2go.org/doku.php) in a dock 4 | 5 | [![Docker Repository on Quay.io](https://quay.io/repository/tatsuya6502/x2go/status "Docker Repository on Quay.io")](https://quay.io/repository/tatsuya6502/x2go) 6 | 7 | - X2Go Server 8 | - Firefox 9 | - Emacs 10 | - rxvt Terminal Emulator 11 | - Japanese fonts 12 | - Ubuntu 16.04 LTS base image 13 | 14 | 15 | ## Running the X2Go Server Container 16 | 17 | Run the script as the followings. This will pull the Docker image 18 | and run it. 19 | 20 | ``` 21 | $ cd docker-x2go 22 | $ ./run.sh 23 | ``` 24 | 25 | It will generate an ssh key at start up and add it to 26 | `/home/docker/.ssh/authorized_keys` in the container. 27 | 28 | ``` 29 | == Use this private key to log in == 30 | -----BEGIN RSA PRIVATE KEY----- 31 | MIIEpAIBAAKCAQEAxb5G8gR40hAGEoRb4t1QDR4+tWeVw3Vgh6N4BaUpxFRFZS3Y 32 | T72VqyNeFTqywuuA2tgF8ZhV1UC+Qxi0EmxoeRQAnt62EUerj1HcVm+MzveT+VWa 33 | ... 34 | ... 35 | ... 36 | -----END RSA PRIVATE KEY----- 37 | ``` 38 | 39 | If the key was not printed, try this command: 40 | 41 | ``` 42 | $ docker logs x2go 43 | ``` 44 | 45 | Save the key to your local PC. 46 | 47 | ``` 48 | # On your local PC 49 | $ vi ~/x2go/x2go-key 50 | $ chmod 600 ~/x2go/x2go-key 51 | ``` 52 | 53 | Start X2Go Client on you PC. Choose **Session** -> **New Session**, 54 | and enter the following information to the **Session** tab. 55 | 56 | - **Server** 57 | * Host: (The IP address of the server) 58 | * Login: `docker` 59 | * SSH port: `2222` 60 | * Use RSA/DSA key for ssh connection: `~/x2go/x2go-key` 61 | 62 | - **Session Type** 63 | * Choose **Custom desktop** and enter `openbox-session` to 64 | the **Command** field. 65 | 66 | Double-click on the session panel to connect. 67 | 68 | 69 | ## Stopping the x2go server 70 | 71 | ``` 72 | $ docker stop x2go 73 | $ docker rm x2go 74 | ``` 75 | -------------------------------------------------------------------------------- /docker/999-sudoers-docker: -------------------------------------------------------------------------------- 1 | ## Allow docker to run all commands without a password 2 | docker ALL=(ALL) NOPASSWD: ALL 3 | 4 | # 5 | # Allow "ssh hostname sudo " without -t (TTY) option, 6 | # because some remote management tools such as Capistrano 7 | # and Vagrant require it. 8 | # 9 | # IMPORTANT: The user must have "NOPASSWORD: ALL" because 10 | # "ssh hostname sudo " will show the password in clear. 11 | # If not, you should run "ssh -t hostname sudo " instead. 12 | # 13 | Defaults:worker !requiretty 14 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu 2 | MAINTAINER Tatsuya Kawano 3 | 4 | # Please change this value to force the builders at Quay.io/Docker Hub 5 | # to omit the cached Docker images. This will have the same effect to 6 | # adding `--no-cache` to `docker build` command. 7 | # 8 | ENV DOCKERFILE_UPDATED 2017-04-02 9 | 10 | RUN (apt-get update && \ 11 | apt-get install -y software-properties-common && \ 12 | add-apt-repository -y ppa:x2go/stable && \ 13 | apt-get update && \ 14 | DEBIAN_FRONTEND=noninteractive apt-get install -y \ 15 | x2goserver x2goserver-xsession ttf-dejavu fonts-ipafont-gothic \ 16 | openbox obconf obmenu conky nitrogen \ 17 | sudo rxvt-unicode-256color \ 18 | firefox emacs) 19 | 20 | RUN (mkdir -p /var/run/sshd && \ 21 | sed -ri 's/UseDNS yes/#UseDNS yes/g' /etc/ssh/sshd_config && \ 22 | echo "UseDNS no" >> /etc/ssh/sshd_config) 23 | # sed -ri 's/UsePAM yes/#UsePAM yes/g' /etc/ssh/sshd_config && \ 24 | # sed -ri 's/#UsePAM no/UsePAM no/g' /etc/ssh/sshd_config) 25 | 26 | # Create a user 27 | RUN (useradd -m docker && \ 28 | mkdir -p /home/docker/.ssh && \ 29 | chmod 700 /home/docker/.ssh && \ 30 | chown docker:docker /home/docker/.ssh && \ 31 | mkdir -p /etc/sudoers.d) 32 | 33 | ADD ./999-sudoers-docker /etc/sudoers.d/999-sudoers-docker 34 | RUN chmod 440 /etc/sudoers.d/999-sudoers-docker 35 | 36 | # Startup script 37 | ADD ./start-sshd.sh /root/start-sshd.sh 38 | RUN chmod 744 /root/start-sshd.sh 39 | 40 | RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 41 | 42 | EXPOSE 22 43 | ENTRYPOINT ["/root/start-sshd.sh"] 44 | -------------------------------------------------------------------------------- /docker/start-sshd.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Create ssh "client" key 4 | # http://stackoverflow.com/a/20977657 5 | 6 | USER_HOME=/home/docker 7 | 8 | KEYGEN=/usr/bin/ssh-keygen 9 | KEYFILE=${USER_HOME}/.ssh/id_rsa 10 | 11 | if [ ! -f $KEYFILE ]; then 12 | $KEYGEN -q -t rsa -N "" -f $KEYFILE 13 | cat $KEYFILE.pub >> ${USER_HOME}/.ssh/authorized_keys 14 | fi 15 | 16 | echo "== Use this private key to log in ==" 17 | cat $KEYFILE 18 | 19 | # Start sshd 20 | /usr/sbin/sshd -D 21 | -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | docker rm x2go 4 | docker run -it -d -p 2222:22 --name=x2go quay.io/tatsuya6502/x2go:latest 5 | sleep 3 6 | docker logs x2go 7 | --------------------------------------------------------------------------------