|
58 | 58 |
|
59 | 59 | logger = get_logger(__name__) |
60 | 60 |
|
| 61 | +JUMP_POD_IMAGE = "testcontainers/sshd:1.3.0@sha256:c50c0f59554dcdb2d9e5e705112144428ae9d04ac0af6322b365a18e24213a6a" |
61 | 62 | JUMP_POD_SSH_PORT = 22 |
62 | 63 | DUMMY_REGION = "-" |
63 | 64 |
|
@@ -832,8 +833,7 @@ def _create_jump_pod_service( |
832 | 833 | containers=[ |
833 | 834 | client.V1Container( |
834 | 835 | 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, |
837 | 837 | command=["/bin/sh"], |
838 | 838 | args=["-c", " && ".join(commands)], |
839 | 839 | ports=[ |
@@ -880,19 +880,22 @@ def _create_jump_pod_service( |
880 | 880 | def _get_jump_pod_commands(authorized_keys: list[str]) -> list[str]: |
881 | 881 | authorized_keys_content = "\n".join(authorized_keys).strip() |
882 | 882 | 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", |
887 | 884 | "chmod 700 ~/.ssh", |
888 | 885 | f"echo '{authorized_keys_content}' > ~/.ssh/authorized_keys", |
889 | 886 | "chmod 600 ~/.ssh/authorized_keys", |
890 | 887 | # regenerate host keys |
891 | 888 | "rm -rf /etc/ssh/ssh_host_*", |
892 | 889 | "ssh-keygen -A > /dev/null", |
893 | 890 | # 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 | + ), |
896 | 899 | ] |
897 | 900 | return commands |
898 | 901 |
|
|
0 commit comments