create-lxc: replace password flow with passwordless SSH key injection
Always authorize the Proxmox host's root pubkey (generate an ed25519 pair if missing) so `ssh root@<lxc>` from the host works immediately. Extra keys via SSH_PUBKEY (literal or path). Relies on Alpine's default PermitRootLogin=prohibit-password — no sshd_config edits, no password ever set; pct enter stays as fallback.
This commit is contained in:
1 parent
d6e846c7a0
commit
1ab70a6f9a
2 files changed
+46
-45
No files matched your search
@@ -34,19 +34,22 @@ HOSTNAME=tunbox MEMORY=512 STORAGE=fast-nvme \
|
||||
bash -c "$(curl -fsSL https://git.d4nn13.de/d4nn13/wirecon/raw/branch/main/proxmox/create-lxc.sh)"
|
||||
```
|
||||
|
||||
Available overrides: `HOSTNAME`, `CORES`, `MEMORY`, `DISK`, `BRIDGE`, `STORAGE`, `TEMPLATE_STORAGE`, `WIRECON_REPO`, `WIRECON_REF`, `ROOT_PASSWORD`, `WIRECON_WEB_AUTOSTART` (yes/no).
|
||||
Available overrides: `HOSTNAME`, `CORES`, `MEMORY`, `DISK`, `BRIDGE`, `STORAGE`, `TEMPLATE_STORAGE`, `WIRECON_REPO`, `WIRECON_REF`, `SSH_PUBKEY`, `WIRECON_WEB_AUTOSTART` (yes/no).
|
||||
|
||||
The script also asks (interactively, default **yes**) whether to enable the web UI on boot. Edit configs in-browser right after provisioning instead of `vi`'ing over `pct enter`.
|
||||
|
||||
### Root login
|
||||
### Shell access (passwordless, key-only)
|
||||
|
||||
The script prompts for a root password (reads from `/dev/tty`, works under `curl | bash`) and, if one is given, installs `openssh`, flips `PermitRootLogin yes`, and enables `sshd`. You can also preset it:
|
||||
No password is ever set. The script installs `openssh`, enables `sshd`, and authorizes root SSH keys:
|
||||
|
||||
```
|
||||
ROOT_PASSWORD='hunter2' bash -c "$(curl -fsSL …/create-lxc.sh)"
|
||||
```
|
||||
- **Always added:** the Proxmox host's `/root/.ssh/id_ed25519.pub`. The script generates this keypair if it doesn't exist, so `ssh root@<lxc-ip>` from the Proxmox host works immediately.
|
||||
- **Optionally added:** whatever you pass in `SSH_PUBKEY` — either a literal key string or a path to a file containing one or more keys. Example:
|
||||
|
||||
Leave it empty / skip the prompt and the container has **no root password** — you enter it from the Proxmox host with `pct enter <VMID>`. SSH won't work in that case.
|
||||
```
|
||||
SSH_PUBKEY=~/.ssh/id_ed25519.pub bash -c "$(curl -fsSL …/create-lxc.sh)"
|
||||
```
|
||||
|
||||
Alpine's default `PermitRootLogin prohibit-password` stays in place — root is reachable with a key, password auth is refused. `pct enter <VMID>` from the Proxmox host remains available as a fallback.
|
||||
|
||||
## Finishing up (inside the LXC)
|
||||
|
||||
|
||||
Reference in new issue
Block a user