LXC: add CONSOLE_AUTOLOGIN option for root autologin on the Proxmox console
This commit is contained in:
+4
-2
@@ -30,11 +30,13 @@ It downloads the Debian 13 template if needed and creates an unprivileged contai
|
|||||||
It then installs everything and prints the container's address. Optional settings: `CTID`, `CT_HOSTNAME`, `STORAGE`
|
It then installs everything and prints the container's address. Optional settings: `CTID`, `CT_HOSTNAME`, `STORAGE`
|
||||||
(`local-lvm`), `TEMPLATE_STORAGE` (`local`), `BRIDGE` (`vmbr0`), `IP` (`dhcp` or `192.168.1.50/24`), `GATEWAY`,
|
(`local-lvm`), `TEMPLATE_STORAGE` (`local`), `BRIDGE` (`vmbr0`), `IP` (`dhcp` or `192.168.1.50/24`), `GATEWAY`,
|
||||||
`VLAN`, `CORES` (1), `MEMORY` (512 MB), `DISK` (4 GB), `PORT` (3000), `SITE_NAME`, `DIGEST_HOUR`, `TZ` (defaults to
|
`VLAN`, `CORES` (1), `MEMORY` (512 MB), `DISK` (4 GB), `PORT` (3000), `SITE_NAME`, `DIGEST_HOUR`, `TZ` (defaults to
|
||||||
the host's), `ROOT_PASSWORD`, `SSH_PUBLIC_KEYS` (a file of keys for root), and
|
the host's), `ROOT_PASSWORD`, `SSH_PUBLIC_KEYS` (a file of keys for root), `CONSOLE_AUTOLOGIN` (0), and
|
||||||
`SMTP_HOST`/`SMTP_PORT`/`SMTP_USER`/`SMTP_PASS`/`SMTP_SECURE` instead of `SMTP_URL`.
|
`SMTP_HOST`/`SMTP_PORT`/`SMTP_USER`/`SMTP_PASS`/`SMTP_SECURE` instead of `SMTP_URL`.
|
||||||
|
|
||||||
`ADMIN_PASSWORD` is only for the web `/admin` page, not the container's root account. To log in at the Proxmox
|
`ADMIN_PASSWORD` is only for the web `/admin` page, not the container's root account. To log in at the Proxmox
|
||||||
console, set `ROOT_PASSWORD`. Without it, get a shell with `pct enter <ctid>` on the host. The console's login screen
|
console, set `ROOT_PASSWORD`, or set `CONSOLE_AUTOLOGIN=1` to have the console log in as root with no password.
|
||||||
|
Anyone who can open the container's console in Proxmox then gets root in it; SSH still can't log in as root without a
|
||||||
|
key. Without either, get a shell with `pct enter <ctid>` on the host. The console's login screen
|
||||||
shows the container's address and the `/admin` URL.
|
shows the container's address and the `/admin` URL.
|
||||||
|
|
||||||
Then point your reverse proxy (HTTPS) at the container's port 3000, open `/admin`, and sign in.
|
Then point your reverse proxy (HTTPS) at the container's port 3000, open `/admin`, and sign in.
|
||||||
|
|||||||
+25
-4
@@ -12,8 +12,10 @@
|
|||||||
# GATEWAY [] VLAN [] CORES [1] MEMORY [512] DISK [4] PORT [3000]
|
# GATEWAY [] VLAN [] CORES [1] MEMORY [512] DISK [4] PORT [3000]
|
||||||
# SMTP_URL MAIL_FROM SITE_NAME DIGEST_HOUR TZ [host's timezone]
|
# SMTP_URL MAIL_FROM SITE_NAME DIGEST_HOUR TZ [host's timezone]
|
||||||
# ROOT_PASSWORD [] SSH_PUBLIC_KEYS [] (a file of public keys for root)
|
# ROOT_PASSWORD [] SSH_PUBLIC_KEYS [] (a file of public keys for root)
|
||||||
# Without ROOT_PASSWORD, root can't log in at the Proxmox console; use
|
# CONSOLE_AUTOLOGIN [0] (1: the Proxmox console logs in as root, no password)
|
||||||
# `pct enter <ctid>` on the host instead. ADMIN_PASSWORD is only for /admin.
|
# Without ROOT_PASSWORD or CONSOLE_AUTOLOGIN=1, root can't log in at the
|
||||||
|
# Proxmox console; use `pct enter <ctid>` on the host instead.
|
||||||
|
# ADMIN_PASSWORD is only for /admin.
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
die () { echo "error: $*" >&2; exit 1; }
|
die () { echo "error: $*" >&2; exit 1; }
|
||||||
@@ -40,6 +42,8 @@ CORES=${CORES:-1}
|
|||||||
MEMORY=${MEMORY:-512}
|
MEMORY=${MEMORY:-512}
|
||||||
DISK=${DISK:-4}
|
DISK=${DISK:-4}
|
||||||
PORT=${PORT:-3000}
|
PORT=${PORT:-3000}
|
||||||
|
CONSOLE_AUTOLOGIN=${CONSOLE_AUTOLOGIN:-0}
|
||||||
|
case "$CONSOLE_AUTOLOGIN" in 0|1) ;; *) die "CONSOLE_AUTOLOGIN must be 0 or 1" ;; esac
|
||||||
TZ=${TZ:-$(cat /etc/timezone 2>/dev/null || timedatectl show -p Timezone --value 2>/dev/null || echo Etc/UTC)}
|
TZ=${TZ:-$(cat /etc/timezone 2>/dev/null || timedatectl show -p Timezone --value 2>/dev/null || echo Etc/UTC)}
|
||||||
|
|
||||||
net="name=eth0,bridge=$BRIDGE,ip=$IP"
|
net="name=eth0,bridge=$BRIDGE,ip=$IP"
|
||||||
@@ -86,11 +90,28 @@ fi
|
|||||||
{
|
{
|
||||||
printf 'Immich Magic Proxy (Debian \\r)\n\n'
|
printf 'Immich Magic Proxy (Debian \\r)\n\n'
|
||||||
printf ' Web: http://\\4{eth0}:%s Admin: %s/admin\n' "$PORT" "$PUBLIC_BASE_URL"
|
printf ' Web: http://\\4{eth0}:%s Admin: %s/admin\n' "$PORT" "$PUBLIC_BASE_URL"
|
||||||
|
if [ "$CONSOLE_AUTOLOGIN" != 1 ]; then
|
||||||
printf ' Login: root at this console needs ROOT_PASSWORD set at install;\n'
|
printf ' Login: root at this console needs ROOT_PASSWORD set at install;\n'
|
||||||
printf ' otherwise run "pct enter %s" on the Proxmox host.\n' "$CTID"
|
printf ' otherwise run "pct enter %s" on the Proxmox host.\n' "$CTID"
|
||||||
printf ' The /admin password is not the root password.\n\n'
|
printf ' The /admin password is not the root password.\n'
|
||||||
|
fi
|
||||||
|
printf '\n'
|
||||||
} | pct exec "$CTID" -- sh -c 'cat > /etc/issue'
|
} | pct exec "$CTID" -- sh -c 'cat > /etc/issue'
|
||||||
|
|
||||||
|
# Console autologin: the Proxmox console (tty1, served by container-getty@1)
|
||||||
|
# logs straight in as root. Anyone with console access to this container in
|
||||||
|
# Proxmox gets root in it; SSH still can't log in as root without a key.
|
||||||
|
if [ "$CONSOLE_AUTOLOGIN" = 1 ]; then
|
||||||
|
log "Enabling root autologin on the Proxmox console"
|
||||||
|
pct exec "$CTID" -- sh -c 'd=/etc/systemd/system/container-getty@1.service.d
|
||||||
|
install -d -m 0755 "$d"
|
||||||
|
printf "%s\n" "[Service]" "ExecStart=" \
|
||||||
|
"ExecStart=-/sbin/agetty --autologin root --noclear --keep-baud tty%I 115200,38400,9600 \$TERM" \
|
||||||
|
> "$d/autologin.conf"
|
||||||
|
systemctl daemon-reload
|
||||||
|
systemctl restart container-getty@1'
|
||||||
|
fi
|
||||||
|
|
||||||
log "Waiting for the network"
|
log "Waiting for the network"
|
||||||
for _ in $(seq 1 60); do
|
for _ in $(seq 1 60); do
|
||||||
pct exec "$CTID" -- sh -c 'getent hosts deb.debian.org >/dev/null' && break
|
pct exec "$CTID" -- sh -c 'getent hosts deb.debian.org >/dev/null' && break
|
||||||
@@ -150,7 +171,7 @@ Immich Magic Proxy is running in container $CTID at http://$address:$PORT
|
|||||||
Next:
|
Next:
|
||||||
1. Point your reverse proxy for $PUBLIC_BASE_URL at http://$address:$PORT
|
1. Point your reverse proxy for $PUBLIC_BASE_URL at http://$address:$PORT
|
||||||
2. Open $PUBLIC_BASE_URL/admin and sign in with ADMIN_PASSWORD
|
2. Open $PUBLIC_BASE_URL/admin and sign in with ADMIN_PASSWORD
|
||||||
Shell: pct enter $CTID (the console login needs ROOT_PASSWORD; /admin uses ADMIN_PASSWORD)
|
Shell: pct enter $CTID (or the Proxmox console, with ROOT_PASSWORD or CONSOLE_AUTOLOGIN=1)
|
||||||
Settings: pct exec $CTID -- nano /etc/immich-magic-proxy/env (then: systemctl restart immich-magic-proxy)
|
Settings: pct exec $CTID -- nano /etc/immich-magic-proxy/env (then: systemctl restart immich-magic-proxy)
|
||||||
Logs: pct exec $CTID -- journalctl -u immich-magic-proxy -f
|
Logs: pct exec $CTID -- journalctl -u immich-magic-proxy -f
|
||||||
Upgrade: pct push $CTID <new tarball> /root/release.tar.gz && pct push $CTID install.sh /root/install.sh --perms 0755 &&
|
Upgrade: pct push $CTID <new tarball> /root/release.tar.gz && pct push $CTID install.sh /root/install.sh --perms 0755 &&
|
||||||
|
|||||||
Reference in New Issue
Block a user