Use SSH with your private key:
ssh -i vscode-key.pem ubuntu@13.251.220.49vscode-key.pem– your SSH private keyubuntu– default EC2 user13.251.220.49– public IP of the EC2 instance
ls /homeShows Linux users like user1, user12, user16, etc.
ps aux | grep code-serverExample output:
user1 588 ... /usr/lib/code-server/lib/node /usr/lib/code-server
user12 1789 ... /usr/lib/code-server/lib/node /usr/lib/code-serverThe port each user is using can be found in their config.yaml.
Each user has a per-user configuration at:
/home/<username>/.config/code-server/config.yaml
Example:
sudo cat /home/user1/.config/code-server/config.yamlOutput:
bind-addr: 127.0.0.1:8081
auth: password
password: DevPassword2026!bind-addr– the local port the code-server listens onauth/password– the login password
⚠️ Note: You needsudoto read other users’ config files.
sudo adduser user36
echo "user36:DevPassword2026!" | sudo chpasswd# Example: assign port 9006
sudo -u user36 mkdir -p /home/user36/.config/code-server
sudo tee /home/user36/.config/code-server/config.yaml > /dev/null <<EOF
bind-addr: 0.0.0.0:9006
auth: password
password: "DevPassword2026!"
cert: false
EOFIf using systemd template:
sudo systemctl enable --now code-server@user36Verify it’s running:
ps aux | grep code-server | grep user36Add a new location block in Nginx config (/etc/nginx/sites-available/default):
# USER 36
location = /user36 { return 301 /user36/; }
location /user36/ {
proxy_pass http://127.0.0.1:9006/;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection upgrade;
proxy_set_header Accept-Encoding gzip;
}9006matches the port in the user’sconfig.yaml
After editing, test and reload Nginx:
sudo nginx -t
sudo systemctl reload nginxURL format:
http://<your-domain-or-IP>/<username>/
Example:
http://13.251.220.49/user36/
Password: DevPassword2026!
Users do not need direct SSH access; Nginx handles routing.
- Always assign a unique port per user to avoid conflicts
- Code-server runs locally (
127.0.0.1); only Nginx exposes it externally - Security Group: Only open ports 22 (SSH), 80 (HTTP), 443 (HTTPS)
- Do NOT open code-server ports (
9001–9006) to the internet