- 在容里面使用如下的命令安装一个ssh 。并设置用户和密码分别是 root 和 admin
apk update && \
apk add --no-cache openssh tzdata && \
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
sed -i "s/#PermitRootLogin.*/PermitRootLogin yes/g" /etc/ssh/sshd_config && \
ssh-keygen -t dsa -P "" -f /etc/ssh/ssh_host_dsa_key && \
ssh-keygen -t rsa -P "" -f /etc/ssh/ssh_host_rsa_key && \
ssh-keygen -t ecdsa -P "" -f /etc/ssh/ssh_host_ecdsa_key && \
ssh-keygen -t ed25519 -P "" -f /etc/ssh/ssh_host_ed25519_key && \
echo "root:admin" | chpasswd
-
在容器内手动启动ssh ,使用如下命令
/usr/sbin/sshd -D -
在自己的机器上使用SCP拉取容器内部的文件
SCP使用参考文档:www.cnblogs.com/hushaojun/p…