Skip to content

Commit d09af48

Browse files
committed
fix(jumpserver): generate the terminal host key before the core starts
The core creates TERMINAL_HOST_KEY in a django_ready handler that runs after the one loading settings, so on first boot the service caches an empty key and KoKo exits with 'ssh: no key found'. Run upgrade_db and the admin step (which boots Django) before starting the service.
1 parent b4bd952 commit d09af48

1 file changed

Lines changed: 17 additions & 10 deletions

File tree

‎install/jumpserver-install.sh‎

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,18 +228,14 @@ mv .output/public /opt/luna
228228
rm -rf /opt/luna-src
229229
msg_ok "Built Luna"
230230

231-
msg_info "Starting Services"
232-
# The core only accepts terminal registration for 5 minutes after it starts,
233-
# so KoKo has to come up right behind it instead of after the long builds
234-
systemctl start jumpserver
235-
for _ in $(seq 1 90); do
236-
curl -fsS -o /dev/null http://127.0.0.1:8080/api/health/ 2>/dev/null && break
237-
sleep 5
238-
done
239-
systemctl start koko
240-
msg_ok "Started Services"
231+
msg_info "Initializing Database"
232+
cd /opt/jumpserver
233+
$STD .venv/bin/python3 jms upgrade_db
234+
msg_ok "Initialized Database"
241235

242236
msg_info "Securing Admin Account"
237+
# Booting Django here (outside upgrade_db) also generates TERMINAL_HOST_KEY,
238+
# so the core service loads it on start instead of caching an empty one
243239
JMS_ADMIN_PASS=$(openssl rand -base64 18 | tr -dc 'a-zA-Z0-9' | cut -c1-16)
244240
cd /opt/jumpserver
245241
PYTHONPATH=/opt/jumpserver/apps DJANGO_SETTINGS_MODULE=jumpserver.settings $STD .venv/bin/python3 -c "
@@ -258,6 +254,17 @@ Password: ${JMS_ADMIN_PASS}
258254
EOF
259255
msg_ok "Secured Admin Account"
260256

257+
msg_info "Starting Services"
258+
# The core only accepts terminal registration for 5 minutes after it starts,
259+
# so KoKo has to come up right behind it instead of after the long builds
260+
systemctl start jumpserver
261+
for _ in $(seq 1 90); do
262+
curl -fsS -o /dev/null http://127.0.0.1:8080/api/health/ 2>/dev/null && break
263+
sleep 5
264+
done
265+
systemctl start koko
266+
msg_ok "Started Services"
267+
261268
msg_info "Configuring Nginx"
262269
cat <<EOF >/etc/nginx/sites-available/jumpserver
263270
server {

0 commit comments

Comments
 (0)