@@ -23,26 +23,27 @@ data:
2323 ssh-keygen -t ed25519 -f /home/dev/ssh_keys/ssh_host_ed25519_key -N ''
2424 fi
2525
26- # Correct permissions for SSH keys
2726 chmod 600 /home/dev/ssh_keys/ssh_host_*
27+
2828 echo "Ensuring run directory exists at /home/dev/run."
2929 mkdir -p /home/dev/run
3030
31+ echo "Currently running sshd processes:"
32+ ps aux | grep sshd
3133
32- echo "Starting SSH service with host keys from /home/dev/ssh_keys on port 2222."
33- /usr/sbin/sshd -D -d -e -f /etc/ssh/sshd_config \
34- -o Port={{ .Values.service.targetPort }} \
35- -o HostKey=/home/dev/ssh_keys/ssh_host_rsa_key \
36- -o HostKey=/home/dev/ssh_keys/ssh_host_ecdsa_key \
37- -o HostKey=/home/dev/ssh_keys/ssh_host_ed25519_key \
38- -o PidFile=/home/dev/run/sshd.pid
34+ echo "Killing any existing sshd processes..."
35+ for pid in $(ps aux | grep sshd | grep -v grep | awk '{print $2}'); do
36+ echo "Killing sshd pid $pid"
37+ kill $pid
38+ done
3939
40- if [ $? -ne 0 ]; then
41- echo "Failed to start SSH service."
42- else
43- echo "SSH service started successfully."
44- fi
40+ echo "Removing stale PID file if exists..."
41+ rm -f /home/dev/run/sshd.pid
4542
46- # Keep the container running if no command is provided
47- echo "No additional command provided, container will keep running."
48- tail -f /dev/null
43+ echo "Starting SSH service..."
44+ exec /usr/sbin/sshd -D -f /etc/ssh/sshd_config \
45+ -o Port=2222 \
46+ -o HostKey=/home/dev/ssh_keys/ssh_host_ed25519_key \
47+ -o HostKey=/home/dev/ssh_keys/ssh_host_rsa_key \
48+ -o HostKey=/home/dev/ssh_keys/ssh_host_ecdsa_key \
49+ -o PidFile=/home/dev/run/sshd.pid
0 commit comments