Skip to content

Generate RDP password at startup - #2

Merged
markcallen merged 10 commits into
mainfrom
docs/docker-quickstart
Aug 26, 2026
Merged

Generate RDP password at startup#2
markcallen merged 10 commits into
mainfrom
docs/docker-quickstart

Conversation

@markcallen

Copy link
Copy Markdown
Contributor

Summary

  • generate an RDP password in the container when RDP_PASSWORD is omitted
  • print generated credentials to container logs and write them to /var/log/hatch/rdp-credentials.log
  • add a Hatch login banner with a partially open hatch in the xterm session
  • update README, INSTALL.md, Compose, and .env.example for the generated-password flow

Verification

  • sh -n scripts/entrypoint.sh
  • sh -n config/startwm.sh
  • sh -n config/login-shell.sh
  • docker build -t hatch:local .
  • docker run -d --name hatch --network host --restart unless-stopped --shm-size=1g --security-opt no-new-privileges:true -e RDP_USER=oauth hatch:local
  • docker logs hatch
  • docker exec hatch sh -lc 'cat /var/log/hatch/rdp-credentials.log && test -x /usr/local/bin/hatch-login-shell'
  • docker run --rm --entrypoint /usr/local/bin/hatch-login-shell hatch:local

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the Hatch container startup flow to auto-generate an RDP password when RDP_PASSWORD is not provided, and updates runtime UX/docs to support retrieving the generated credentials.

Changes:

  • Generate an RDP password at container startup when RDP_PASSWORD is omitted and surface credentials via container logs and an in-container credentials file.
  • Add a dedicated login shell banner displayed in the xterm session launched by the XRDP session window manager.
  • Update Compose and documentation to reflect the generated-password flow (no longer requiring RDP_PASSWORD to be set up-front).

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
scripts/entrypoint.sh Generates password when missing; writes/logs credentials during container startup
README.md Updates run instructions to rely on generated password and docker logs
INSTALL.md Updates install/start/verification steps for generated-password flow
Dockerfile Installs new login shell script into the image and marks it executable
docker-compose.yml Makes RDP_PASSWORD optional to enable auto-generation
config/startwm.sh Launches xterm using the new hatch-login-shell entrypoint
config/login-shell.sh New script that prints a Hatch banner and execs a login bash shell
.env.example Documents leaving RDP_PASSWORD blank to auto-generate
Suppressed comments (2)

scripts/entrypoint.sh:17

  • The credentials file always labels the timestamp as "Generated:" even when the password was provided via RDP_PASSWORD. This is misleading; rename it to a neutral label (or make it conditional).
  echo "Generated: $(date -u '+%Y-%m-%dT%H:%M:%SZ')"

scripts/entrypoint.sh:11

  • chpasswd consumes user:password lines; if a user-supplied RDP_PASSWORD contains ':' or a newline, the input format breaks and can set an unintended password. Validate RDP_PASSWORD before piping it into chpasswd.
if ! id "$RDP_USER" >/dev/null 2>&1; then useradd --create-home --shell /bin/bash "$RDP_USER"; fi
printf '%s:%s\n' "$RDP_USER" "$RDP_PASSWORD" | chpasswd

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread scripts/entrypoint.sh
Comment on lines +6 to +9
if [ -z "${RDP_PASSWORD:-}" ]; then
RDP_PASSWORD="$(openssl rand -hex 24)"
GENERATED_PASSWORD=1
fi

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

scripts/entrypoint.sh:9

  • entrypoint.sh now relies on openssl rand to generate a password when RDP_PASSWORD is unset, but the image build does not explicitly install the openssl CLI. If openssl is missing at runtime, the entrypoint will exit (due to set -e) and the container won't start. Consider adding a fallback that does not depend on openssl (e.g., /dev/urandom + od), or explicitly install openssl in the image.
if [ -z "${RDP_PASSWORD:-}" ]; then
  RDP_PASSWORD="$(openssl rand -hex 24)"
  GENERATED_PASSWORD=1
fi

Comment thread scripts/entrypoint.sh
Comment on lines +18 to +23
{
echo "Hatch RDP credentials"
echo "Generated: $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
echo "RDP user: $RDP_USER"
echo "RDP password: $RDP_PASSWORD"
} > /var/log/hatch/rdp-credentials.log
@markcallen
markcallen requested a lite review from Copilot August 26, 2026 15:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 6 comments.

Comment on lines +47 to +49
location = / {
return 302 https://\$http_host/guacamole/;
}
Comment thread scripts/entrypoint.sh
Comment on lines +22 to +27
{
echo "Hatch RDP credentials"
echo "Written: $(date -u '+%Y-%m-%dT%H:%M:%SZ')"
echo "RDP user: $RDP_USER"
echo "RDP password: $RDP_PASSWORD"
} > /var/log/hatch/rdp-credentials.log
Comment thread scripts/entrypoint.sh
Comment on lines +37 to +43
if [ "$GENERATED_PASSWORD" -eq 1 ]; then
echo "Generated RDP password: $RDP_PASSWORD"
echo "Generated RDP credentials were also written to /var/log/hatch/rdp-credentials.log"
else
echo "Using RDP password from RDP_PASSWORD"
echo "RDP credentials were also written to /var/log/hatch/rdp-credentials.log"
fi
Comment thread scripts/entrypoint.sh Outdated
Comment on lines +18 to +20
install -d -m 0755 /etc/hatch
printf '%s\n' "${HATCH_START_URL:-about:blank}" > /etc/hatch/start-url
chmod 0644 /etc/hatch/start-url
Comment thread Dockerfile
libwebsockets-dev \
uuid-dev \
wget \
&& wget -O /tmp/guacamole-server.tar.gz "https://archive.apache.org/dist/guacamole/${GUACAMOLE_VERSION}/source/guacamole-server-${GUACAMOLE_VERSION}.tar.gz" \
Comment thread scripts/healthcheck.sh Outdated
set -eu
pgrep -x nginx >/dev/null
pgrep -x guacd >/dev/null
pgrep -f 'org.apache.catalina.startup.Bootstrap' >/dev/null

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

Suppressed comments (3)

Previously missed (3) — in code that hasn't changed since the last review.

Dockerfile:37

  • GUACAMOLE_VERSION is parameterized for the guacd build, but the guacamole-web stage is pinned to guacamole/guacamole:1.6.0. If GUACAMOLE_VERSION is changed later, guacd and the webapp can silently drift to different versions.
FROM guacamole/guacamole:1.6.0 AS guacamole-web

FROM debian:12-slim

scripts/entrypoint.sh:51

  • When RDP_PASSWORD is generated (GENERATED_PASSWORD=1), the startup logs never print the actual generated RDP password—unless Guacamole happens to reuse it. If GUAC_USER/GUAC_PASSWORD are set to custom values, the log line saying generated credentials were printed becomes misleading, and users running detached won’t be able to retrieve the generated RDP password from logs.
if [ "$GENERATED_PASSWORD" -eq 1 ]; then
  echo "Generated RDP credentials were printed as Guacamole credentials and written to /var/log/hatch/rdp-credentials.log"
else
  echo "Using RDP password from RDP_PASSWORD"
  echo "RDP credentials were also written to /var/log/hatch/rdp-credentials.log"

scripts/e2e-guacamole.sh:124

  • This check embeds the URL into a pgrep regex inside single quotes. URLs can contain regex metacharacters (e.g., .) and may also contain quotes if overridden via env, which can cause false positives/negatives or break the command. Prefer passing the URL via an env var and using fixed-string matching.
  if docker exec "${PREFIX}-hatch" sh -lc "pgrep -af 'chromium.*${URL}' >/dev/null"; then

Comment thread scripts/healthcheck.sh Outdated
Comment on lines 7 to 11
HTTPS_PORT_HEX="$(printf '%04X' "${HATCH_HTTPS_PORT:-443}")"
grep -qi ":$HTTPS_PORT_HEX " /proc/net/tcp /proc/net/tcp6 2>/dev/null
grep -qi ':1F90 ' /proc/net/tcp /proc/net/tcp6 2>/dev/null
grep -qi ':12D6 ' /proc/net/tcp /proc/net/tcp6 2>/dev/null
grep -qi ':0D3D ' /proc/net/tcp /proc/net/tcp6 2>/dev/null
@markcallen
markcallen merged commit f9cffac into main Aug 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants