ssh to dev-container
Check SSH Service Status [in dev-container]
- Verified if SSH service was already running in the container
- Found no SSH daemon running initially
Install OpenSSH Server [in dev-container]
- Used
sudo apt install -y openssh-serverto install SSH server package - System automatically generated SSH host keys during installation
- Used
Start SSH Service [in dev-container]
- Executed
sudo service ssh startto launch SSH daemon - Confirmed SSH was listening on port 22 using
netstat -tlnp
- Executed
Configure SSH Security Settings [in dev-container]
- Modified
/etc/ssh/sshd_configto enable root login:PermitRootLogin yes - Enabled password authentication:
PasswordAuthentication yes
- Modified
Set Root Password [in dev-container]
- Set root user password to “123456” using
echo "root:123456" | sudo chpasswd - Cleared and reset password when authentication issues occurred
- Set root user password to “123456” using
Restart SSH Service [in dev-container]
- Applied configuration changes with
sudo service ssh restart - Ensured all settings took effect
- Applied configuration changes with
Regenerate Host Keys [in dev-container]
- Removed old host keys with
sudo rm -f /etc/ssh/ssh_host_* - Generated new keys using
sudo ssh-keygen -A - Resolved host key verification conflicts
- Removed old host keys with
Test SSH Connectivity [in dev-container]
- Tested internal SSH connection using
sshpass -p "123456" ssh -o StrictHostKeyChecking=no root@localhost - Verified successful authentication and command execution
- Confirmed external SSH connection works through port forwarding
- Tested internal SSH connection using
Setup Port Forwarding and Provide Connection Instructions [in dev-container + on local machine]
- Map the current dev container’s port 22 to the host’s port 65345(or other), enabling external applications to connect to the SSH service inside the container
- Configured port forwarding:
localhost:65345(or other)→container:22in VS Code/Cursor - Created
~/.ssh/configfile on the host machine and added connection settings - Guided user through VS Code Remote SSH extension setup or terminal connection
SSH Configuration (~/.ssh/config):
After completing the above process, you need to manually add this content to your SSH config file, then connect through kirocode
1 | Host dev-container |
ssh to dev-container
https://zhoujingfighting.github.io/ssh/dev-container/2026-06-10-devcontainer/