on main help sign in
fix: now fixed ssh problem
commit27e5733c9302350e782585b1d3006fecb760cf08 authorrobcholz <84130577+robcholz@users.noreply.github.com> dateFri 6 Feb 2026, 21:15 (8 months ago) parent1cb669b
3 files changed+66−30
src/instance.rs+1−1 src/provision.sh+23−1 src/ssh.sh+42−28
src/instance.rs+1−1
@@ -31,7 +31,7 @@ const SSH_KEY_NAME: &str = "ssh_key";
3131const SERIAL_LOG_NAME: &str = "serial.log";
3232const SSH_GUEST_DIR: &str = "/root/.vibebox";
3333const DEFAULT_SSH_USER: &str = "vibebox";
34−const SSH_CONNECT_RETRIES: usize = 20;
34+const SSH_CONNECT_RETRIES: usize = 30;
3535const SSH_CONNECT_DELAY_MS: u64 = 500;
3636const SSH_SETUP_SCRIPT: &str = include_str!("ssh.sh");
3737
src/provision.sh+23−1
@@ -15,13 +15,35 @@ apt-get install -y --no-install-recommends \
1515 git \
1616 ripgrep \
1717 openssh-server \
18+ locales \
1819 sudo
1920
2021# Set hostname to "vibe" so it's clear that you're inside the VM.
2122hostnamectl set-hostname vibe
2223
23−# Enable SSH server so instances can use key-based auth.
24+# Locale (fix: setlocale: LC_CTYPE ... UTF-8)
25+sed -i 's/^# *en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen
26+locale-gen
27+update-locale LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8
28+
29+# SSH: host keys + base config (doesn't depend on runtime user)
30+ssh-keygen -A
31+mkdir -p /etc/ssh/sshd_config.d
32+cat >/etc/ssh/sshd_config.d/10-vibebox-base.conf <<'EOF'
33+PasswordAuthentication no
34+KbdInteractiveAuthentication no
35+ChallengeResponseAuthentication no
36+PubkeyAuthentication yes
37+PermitRootLogin no
38+
39+# Speed up logins / avoid DNS delays
40+UseDNS no
41+GSSAPIAuthentication no
42+EOF
43+
44+sshd -t
2445systemctl enable ssh
46+systemctl restart ssh
2547
2648# Set this env var so claude doesn't complain about running as root.'
2749echo "export IS_SANDBOX=1" >> .bashrc
src/ssh.sh+42−28
@@ -1,46 +1,60 @@
11#!/bin/sh
2+set -eu
23
34SSH_USER="__SSH_USER__"
4−SUDO_PASSWORD="__SUDO_PASSWORD__"
55PROJECT_NAME="__PROJECT_NAME__"
66KEY_PATH="__KEY_PATH__"
77
8−if [ -d /root/${PROJECT_NAME}/.vibebox ]; then
9− mount -t tmpfs tmpfs /root/${PROJECT_NAME}/.vibebox
8+# 1) tmpfs mount
9+TARGET="/root/${PROJECT_NAME}/.vibebox"
10+if [ -d "$TARGET" ] && ! mountpoint -q "$TARGET"; then
11+ mount -t tmpfs tmpfs "$TARGET"
1012fi
1113
12−if ! command -v sshd >/dev/null 2>&1; then
13− apt-get update && apt-get install -y openssh-server sudo
14+# 2)
15+if ! id -u "$SSH_USER" >/dev/null 2>&1; then
16+ useradd -m -s /bin/bash -U "$SSH_USER"
17+ usermod -aG sudo "$SSH_USER" || true
1418fi
1519
16−systemctl enable ssh >/dev/null 2>&1 || true
17−id -u ${SSH_USER} >/dev/null 2>&1 || useradd -m -s /bin/bash ${SSH_USER}
18−echo "${SSH_USER}:${SUDO_PASSWORD}" | chpasswd
19−usermod -aG sudo ${SSH_USER}
20−install -d -m 700 /home/${SSH_USER}/.ssh
21−install -m 600 ${KEY_PATH} /home/${SSH_USER}/.ssh/authorized_keys
22−chown -R ${SSH_USER}:${SSH_USER} /home/${SSH_USER}/.ssh
23−rm -f /home/${SSH_USER}/.bash_logout
24−mkdir -p /etc/ssh/sshd_config.d
25−cat >/etc/ssh/sshd_config.d/vibebox.conf <<'VIBEBOX_SSHD'
26−PasswordAuthentication no
27−KbdInteractiveAuthentication no
28−ChallengeResponseAuthentication no
29−PubkeyAuthentication yes
30−PermitRootLogin no
31−AllowUsers __SSH_USER__
32−VIBEBOX_SSHD
33−systemctl restart ssh
20+install -d -m 700 -o "$SSH_USER" -g "$SSH_USER" "/home/${SSH_USER}/.ssh"
21+install -m 600 -o "$SSH_USER" -g "$SSH_USER" "$KEY_PATH" "/home/${SSH_USER}/.ssh/authorized_keys"
22+
23+# 3)
24+systemctl start ssh >/dev/null 2>&1 || true
25+
26+# 4)
27+i=0
28+while :; do
29+ if ss -lnt 2>/dev/null | awk '{print $4}' | grep -qE '(:22)$'; then
30+ break
31+ fi
32+ i=$((i+1))
33+ [ "$i" -ge 40 ] && break # ~4s
34+ sleep 0.1
35+done
36+
3437echo VIBEBOX_SSH_READY
3538
36−echo "=== generated network file ==="
37−sed -n '1,200p' /run/systemd/network/10-netplan-all-en.network || true
39+find_ip() {
40+ if command -v ip >/dev/null 2>&1; then
41+ ip -4 -o addr show scope global 2>/dev/null | awk '{print $4}' | cut -d/ -f1 | head -n 1
42+ return
43+ fi
44+ if command -v hostname >/dev/null 2>&1; then
45+ hostname -I 2>/dev/null | awk '{print $1}'
46+ return
47+ fi
48+}
3849
39−while true; do
40− ip=$(ip -4 -o addr show scope global | awk '{print $4}' | cut -d/ -f1 | head -n 1)
50+i=0
51+while :; do
52+ ip="$(find_ip || true)"
4153 if [ -n "$ip" ]; then
4254 echo VIBEBOX_IPV4=$ip
4355 break
4456 fi
45− sleep 1
57+ i=$((i+1))
58+ [ "$i" -ge 60 ] && break
59+ sleep 0.5
4660done