Skip to content

Commit 4d2152b

Browse files
committed
fix: robust agent user setup and document network routing
Cloud-init runcmd now explicitly creates the agent user with SSH key, handling cases where cloud-init's users section fails silently or the base image has unexpected state. README documents the route command needed after colima start with --network-address to reach containers on the Incus bridge network.
1 parent 1c666b4 commit 4d2152b

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,18 @@ brew install colima incus
1717
colima start --profile incus --vm-type vz --vz-rosetta --network-address
1818
```
1919

20+
The `--network-address` flag assigns a routable IP to the VM. After starting, add a route so your Mac can reach containers on the Incus bridge network:
21+
22+
```bash
23+
# Get the VM's IP address
24+
VM_IP=$(colima list -p incus -j | jq -r '.address')
25+
26+
# Add route to container network (persists until reboot)
27+
sudo route add -net 192.100.0.0/24 $VM_IP
28+
```
29+
30+
To make routing persistent across reboots, add a LaunchDaemon or re-run after `colima start`.
31+
2032
Build and initialize:
2133

2234
```bash

coop

0 Bytes
Binary file not shown.

internal/cloudinit/userdata.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,20 @@ write_files:
9393
permissions: '0644'
9494
9595
runcmd:
96+
# Ensure agent user exists with correct shell (handles UID conflicts)
97+
- id agent >/dev/null 2>&1 || useradd -m -s /bin/bash -u 1000 -U agent
98+
- usermod -s /bin/bash agent
99+
- usermod -aG sudo,adm agent || true
100+
- 'echo "agent ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/agent'
101+
96102
# Setup agent home directories
97103
- mkdir -p /home/agent/.bashrc.d /home/agent/.local/bin /home/agent/.config
98104
- mkdir -p /home/agent/.ssh /home/agent/.vscode-server /home/agent/workspace /home/agent/go/bin
99105
- chmod 700 /home/agent/.ssh
106+
{{- if .SSHPubKey }}
107+
- 'echo "{{.SSHPubKey}}" > /home/agent/.ssh/authorized_keys'
108+
- chmod 600 /home/agent/.ssh/authorized_keys
109+
{{- end }}
100110
- 'grep -q "bashrc.d" /home/agent/.bashrc || echo "for f in ~/.bashrc.d/*.sh; do [ -r \"$f\" ] && . \"$f\"; done" >> /home/agent/.bashrc'
101111
102112
# Optional upgrades (non-fatal)

0 commit comments

Comments
 (0)