# 在Docker容器中操作宿主机
# 在宿主机上生成 ssh key
ssh-keygen -t rsa -b 4096
1
# 把 Public Key 加入到 authorized_keys
cat /root/.ssh/id_rsa.pub > ~/.ssh/authorized_keys
1
# 把 Private Key 挂载到容器中
/root/.ssh/id_rsa:/root/.ssh/id_rsa
1
# 进入容器&安装 ssh
apk add openssh
1
# ssh执行外部脚本
ssh root@100.10.222.11 "sh /usr/local/docker/vuepress/run.sh; echo done!"
1