5PROJECT_NAME="__PROJECT_NAME__"
8diag() { echo "[vibebox][diag] $*" >&2; }
10# Extract default route facts (no hardcode)
11default_route_line() { ip -4 route show default 2>/dev/null | head -n 1 || true; }
13 default_route_line | awk '{for(i=1;i<=NF;i++) if($i=="dev"){print $(i+1); exit}}'
16 default_route_line | awk '{for(i=1;i<=NF;i++) if($i=="via"){print $(i+1); exit}}'
20 diag "=== default route ==="
21 default_route_line >&2 || true
23 diag "=== systemctl status ssh ==="
24 systemctl status ssh --no-pager >&2 || true
26 diag "=== journalctl -u ssh (tail) ==="
27 journalctl -u ssh -n 120 --no-pager >&2 || true
29 diag "=== sshd -t ==="
32 diag "=== sshd -T (listen/addressfamily) ==="
33 sshd -T 2>/dev/null | egrep -i '^(listenaddress|addressfamily|port|permitrootlogin|allowusers)\b' >&2 || true
35 diag "=== listeners on :22 ==="
36 ss -lntp 2>/dev/null | awk 'NR==1 || $4 ~ /:22$/' >&2 || true
38 diag "=== ip -br addr ==="
39 ip -br addr >&2 || true
41 diag "=== ip route ==="
44 gw="$(default_gw || true)"
46 diag "=== ping default gateway ($gw) ==="
47 ping -c1 -W1 "$gw" >/dev/null 2>&1 && diag "ping gw OK" || diag "ping gw FAIL"
52TARGET="/root/${PROJECT_NAME}/.vibebox"
53if [ -d "$TARGET" ] && ! mountpoint -q "$TARGET"; then
54 mount -t tmpfs tmpfs "$TARGET"
57# 2) user + authorized_keys
58if ! id -u "$SSH_USER" >/dev/null 2>&1; then
59 useradd -m -s /bin/bash -U "$SSH_USER"
60 usermod -aG sudo "$SSH_USER" || true
63install -d -m 700 -o "$SSH_USER" -g "$SSH_USER" "/home/${SSH_USER}/.ssh"
64install -m 600 -o "$SSH_USER" -g "$SSH_USER" "$KEY_PATH" "/home/${SSH_USER}/.ssh/authorized_keys"
66USER_HOME="$(getent passwd "$SSH_USER" | cut -d: -f6 2>/dev/null || true)"
67if [ -z "$USER_HOME" ]; then
68 USER_HOME="/home/${SSH_USER}"
71# Home mount links (config-driven)
74# Vibebox shell commands
75install -d -m 755 /etc/profile.d
76cat > /etc/profile.d/vibebox.sh <<'VIBEBOX_SHELL_EOF'
77__VIBEBOX_SHELL_SCRIPT__
79chmod 644 /etc/profile.d/vibebox.sh
81if ! grep -q "vibebox-aliases" "${USER_HOME}/.bashrc" 2>/dev/null; then
84 echo "# vibebox-aliases"
85 echo ". /etc/profile.d/vibebox.sh"
86 } >> "${USER_HOME}/.bashrc"
90MISE_BIN="${USER_HOME}/.local/bin/mise"
91if [ ! -x "$MISE_BIN" ] && ! command -v mise >/dev/null 2>&1; then
92 curl https://mise.run | HOME="$USER_HOME" sh
94echo 'eval "$(~/.local/bin/mise activate bash)"' >> "${USER_HOME}/.bashrc"
96export PATH="${USER_HOME}/.local/bin:/usr/local/bin:$PATH"
98mkdir -p "${USER_HOME}/.config/mise"
100cat > "${USER_HOME}/.config/mise/config.toml" <<MISE
102 # Always use the venv created by uv, if available in directory
103 python.uv_venv_auto = true
105 idiomatic_version_file_enable_tools = ["rust"]
110 "npm:@openai/codex" = "latest"
111 "npm:@anthropic-ai/claude-code" = "latest"
114touch "${USER_HOME}/.config/mise/mise.lock"
115if [ -x "$MISE_BIN" ]; then
116 HOME="$USER_HOME" "$MISE_BIN" install
118 HOME="$USER_HOME" mise install
121# 3) start ssh (don't swallow failures)
122# If ssh is already active, don't force start/restart.
123if ! systemctl is-active --quiet ssh; then
124 if ! systemctl start ssh; then
125 diag "systemctl start ssh failed"
131# 4) obtain stable IPv4 on the default-route interface (wait up to ~30s)
134 ip -4 -o addr show dev "$dev" scope global 2>/dev/null \
135 | awk '{print $4}' | cut -d/ -f1 | head -n 1 || true
142while [ "$t" -lt 60 ]; do
143 dev="$(default_dev || true)"
144 gw="$(default_gw || true)"
145 if [ -n "$dev" ]; then
146 ip="$(ip_on_dev "$dev")"
151 if [ -n "$dev" ] && [ -n "$ip" ]; then
152 # optional: if a gateway exists, require it to answer to avoid "ip exists but link dead"
153 if [ -z "$gw" ] || ping -c1 -W1 "$gw" >/dev/null 2>&1; then
162if [ -z "$dev" ] || [ -z "$ip" ]; then
163 diag "no stable IPv4 on default route interface"
168# 5) strong verify: ssh must listen externally (0.0.0.0:22 or $ip:22 or [::]:22)
170 ss -lnt 2>/dev/null \
171 | awk 'NR>1 {print $4}' \
172 | grep -Eq "^(0\.0\.0\.0:22|\\[::\\]:22|${ip}:22)$"
176while ! listens_ok && [ "$i" -lt 80 ]; do # ~8s
182 diag "sshd not listening on 0.0.0.0:22 / ${ip}:22"
187echo VIBEBOX_SSH_READY
188echo "VIBEBOX_IPV4=$ip"
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list