diff --git a/src/docker-images/init-container/runtime/sync.py b/src/docker-images/init-container/runtime/sync.py index b3ea080e7..a9754df51 100644 --- a/src/docker-images/init-container/runtime/sync.py +++ b/src/docker-images/init-container/runtime/sync.py @@ -92,7 +92,12 @@ def main(args): pod_name = get_pod_name() job_name = get_job_name() ip = get_pod_ip() - ssh_port = find_free_port() + + if os.environ.get("DLWS_HOST_NETWORK") == "enable": + ssh_port = find_free_port() + else: + ssh_port = 22 + ps_num = get_ps_number() worker_num = get_worker_number() expected_num = ps_num + worker_num diff --git a/src/init-scripts/setup_sshd.sh b/src/init-scripts/setup_sshd.sh index 4bd9e104e..916ea68c6 100644 --- a/src/init-scripts/setup_sshd.sh +++ b/src/init-scripts/setup_sshd.sh @@ -24,14 +24,9 @@ function retry { } function setup_sshd { - # if "DLWS_HOST_NETWORK" enabled, randomly generate port in range: 40000-49999 - if [ "$DLWS_HOST_NETWORK" = "enable" ]; - then - SSH_PORT=$DLWS_SD_SELF_SSH_PORT - sed -i -E "s/^#?Port 22/Port ${SSH_PORT}/" /etc/ssh/sshd_config || exit 1 - else - SSH_PORT=22 - fi + SSH_PORT=$DLWS_SD_SELF_SSH_PORT + sed -i -E "s/^#?Port 22/Port ${SSH_PORT}/" /etc/ssh/sshd_config || exit 1 + echo "${SSH_PORT}" > ${PROC_DIR}/SSH_PORT echo "${POD_IP}" > ${PROC_DIR}/POD_IP