Deploy a custom Docker image to your Pod
#!/bin/bash # Install SSH server apt-get update apt-get install -y openssh-server # Configure SSH mkdir -p /var/run/sshd sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin prohibit-password/' /etc/ssh/sshd_config sed -i 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' /etc/pam.d/sshd # Set up SSH key if [ ! -z "$PUBLIC_KEY" ]; then mkdir -p /root/.ssh echo "$PUBLIC_KEY" > /root/.ssh/authorized_keys chmod 700 /root/.ssh chmod 600 /root/.ssh/authorized_keys fi # Set SSH port if [ ! -z "$SSH_PORT" ]; then sed -i "s/#Port 22/Port $SSH_PORT/" /etc/ssh/sshd_config fi # Start SSH service /usr/sbin/sshd -D
SSH_PORT
1234
PUBLIC_KEY
ssh-rsa AAAAB3NzaC1yc2E...
ssh -p <SSH_PORT> root@<POD_IP>