Skip to content

Commit 393af5b

Browse files
committed
update ssh support for container
1 parent b6b1c2f commit 393af5b

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,28 @@ This repository contains everything needed to set up the Picker tool's complete
4040
Ubuntu 22.04, Python 3.10 + essential development tools + additional frameworks (e.g. toffee, XSPdb, etc.)
4141
> Note: The full image is larger and may take longer to download, but it includes everything you need to get started with the UnityChip tutorial environment.
4242

43+
3. How to run the image
44+
45+
Start with shell access:
46+
```sh
47+
# 1. If shell is enough for you, run the image with the following command:
48+
docker run -it --network host ghcr.io/xs-mlvp/envfull:latest
49+
# 2. If you want to use ssh or vscode remote development, run this command in the container:
50+
sudo service ssh start
51+
```
52+
> Note: The `--network host` flag allows the container to use the host's network stack. This is useful for accessing services running on the host machine.
53+
54+
Start with SSH access:
55+
```sh
56+
# 1. If you want to use ssh or vscode remote development, run the image with the following command:
57+
docker run -itd --network host ghcr.io/xs-mlvp/envfull:latest sudo /usr/sbin/sshd -D
58+
# 2. SSH into the container (security reason: /etc/ssh/sshd_config is set to only listen to localhost)
59+
ssh -p 51202 user@localhost # password: user
60+
# 3. (Optional) If you are running container on a remote server, you can use the following command port forwarding when connecting to the remote server:
61+
ssh -L 51202:localhost:51202 <your-server-user>@<your-remote-server-ip>
62+
```
63+
> Note: The container ssh port is hardcoded to 51202, so you need to specify this port when connecting. The default password is `user`. You can change it by modifying the Dockerfile or the sshd_config file in the container. The `-D` flag runs the SSH daemon in the foreground, which is necessary for the container to keep running.
64+
4365
### Build Your Own Image 🔨
4466
4567
If you want to build your own image, you can use the provided Dockerfile. This is useful if you want to customize the environment or add additional tools.

docker/Dockerfile

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,17 @@ RUN useradd -m -s /bin/bash user && \
114114
chown user:user -R /workspace && \
115115
chmod 755 /workspace
116116

117+
# Set SSH autostart
118+
RUN mkdir /var/run/sshd && \
119+
echo 'root:root' | chpasswd && \
120+
sed -i 's|#PermitRootLogin prohibit-password|PermitRootLogin yes|' /etc/ssh/sshd_config && \
121+
sed -i 's|#PasswordAuthentication yes|PasswordAuthentication yes|' /etc/ssh/sshd_config && \
122+
sed -i 's|#PermitEmptyPasswords no|PermitEmptyPasswords yes|' /etc/ssh/sshd_config && \
123+
sed -i 's|#Port 22|Port 51202|' /etc/ssh/sshd_config && \
124+
# only listen on localhost
125+
sed -i 's|#ListenAddress|ListenAddress 127.0.0.1 #|' /etc/ssh/sshd_config && \
126+
ssh-keygen -A
127+
117128
# Switch to the new user
118129
USER user
119130
# Set the default shell to bash

0 commit comments

Comments
 (0)