# attach containerpodmanexec-it wechar_build2 bash# install ssh package and generate ssh keyapt update &&aptinstall openssh-server && ssh-keygen -f /etc/ssh/ssh_host_rsa_key -N''# generate ssh public key to be used in such as git
ssh-keygen -q-t rsa -N''-f ~/.ssh/id_rsa
# change the Port in /etc/ssh/sshd_configecho Port 3368>> /etc/ssh/sshd_config
# startup sshdservicessh start
# To debug the sshd, you can run cmd: /usr/sbin/sshd -p3368 -D -d -e# add your local public key (~/.ssh/id_rsa.pub) to container ~/.ssh/authorized_keys # to support ssh login through ssh keyvim ~/.ssh/authorized_keys
配置ssh连接
# ~/.ssh/config
Host dev_container2
User root
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
ServerAliveInterval 15
HostName 10.169.5.104
Port 3368
IdentityFile ~/.ssh/id_rsa
ProxyCommand ssh WAN-Jump02 -W %h:%p