Skip to content

Commit da4943d

Browse files
authored
Kubernetes: change jump pod image, tune sshd options (#3273)
Part-of: #3126
1 parent f5ca910 commit da4943d

File tree

1 file changed

+11
-8
lines changed
  • src/dstack/_internal/core/backends/kubernetes

1 file changed

+11
-8
lines changed

src/dstack/_internal/core/backends/kubernetes/compute.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
logger = get_logger(__name__)
6060

61+
JUMP_POD_IMAGE = "testcontainers/sshd:1.3.0@sha256:c50c0f59554dcdb2d9e5e705112144428ae9d04ac0af6322b365a18e24213a6a"
6162
JUMP_POD_SSH_PORT = 22
6263
DUMMY_REGION = "-"
6364

@@ -832,8 +833,7 @@ def _create_jump_pod_service(
832833
containers=[
833834
client.V1Container(
834835
name=f"{pod_name}-container",
835-
# TODO: Choose appropriate image for jump pod
836-
image="dstackai/base:py3.11-0.4rc4",
836+
image=JUMP_POD_IMAGE,
837837
command=["/bin/sh"],
838838
args=["-c", " && ".join(commands)],
839839
ports=[
@@ -880,19 +880,22 @@ def _create_jump_pod_service(
880880
def _get_jump_pod_commands(authorized_keys: list[str]) -> list[str]:
881881
authorized_keys_content = "\n".join(authorized_keys).strip()
882882
commands = [
883-
# prohibit password authentication
884-
'sed -i "s/.*PasswordAuthentication.*/PasswordAuthentication no/g" /etc/ssh/sshd_config',
885-
# create ssh dirs and add public key
886-
"mkdir -p /run/sshd ~/.ssh",
883+
"mkdir -p ~/.ssh",
887884
"chmod 700 ~/.ssh",
888885
f"echo '{authorized_keys_content}' > ~/.ssh/authorized_keys",
889886
"chmod 600 ~/.ssh/authorized_keys",
890887
# regenerate host keys
891888
"rm -rf /etc/ssh/ssh_host_*",
892889
"ssh-keygen -A > /dev/null",
893890
# start sshd
894-
f"/usr/sbin/sshd -p {JUMP_POD_SSH_PORT} -o PermitUserEnvironment=yes",
895-
"sleep infinity",
891+
(
892+
f"/usr/sbin/sshd -D -e -p {JUMP_POD_SSH_PORT}"
893+
" -o LogLevel=ERROR"
894+
" -o PasswordAuthentication=no"
895+
" -o AllowTcpForwarding=local"
896+
# proxy jumping only, no shell access
897+
" -o ForceCommand=/bin/false"
898+
),
896899
]
897900
return commands
898901

0 commit comments

Comments
 (0)