Setting Up SSH Access
To set up SSH access on a customer Docker image, you need to add the following script to your templates startup script:
#!/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
Environment Variables
Configure these environment variables in your template settings to customize SSH access:
Variable | Description | Example Value |
---|
SSH_PORT | Custom SSH port | 1234 |
PUBLIC_KEY | Your SSH public key for authentication | ssh-rsa AAAAB3NzaC1yc2E... |
Connecting via SSH
Once your Pod is running with SSH configured, you can connect using:
ssh -p <SSH_PORT> root@<POD_IP>