内容纲要

Dockerfile

FROM fedora:latest
ENV LANG en_US.utf8

RUN yum -y update && \
yum -y install yum-fastestmirror

#ADD http://mirrors.163.com/.help/fedora-163.repo http://mirrors.163.com/.help/fedora-updates-163.repo /etc/yum.repos.d/

RUN curl -o /etc/yum.repos.d/fedora-updates-163.repo http://mirrors.163.com/.help/fedora-updates-163.repo && \
curl -o /etc/yum.repos.d/fedora-163.repo http://mirrors.163.com/.help/fedora-163.repo && \
yum clean all && \
yum makecache

RUN yum -y update && \
yum -y groupinstall ‘Development Tools’ && \
yum -y install passwd git clang gcc gcc-c++ make pkgconfig scons && \
yum -y install openssh-server vim rsync && \
yum -y install curl wget && \
yum -y install glibc-devel glibc-headers glibc-static && \
yum -y install openssl openssl-devel zlib zlib-devel pcre pcre-devel && \
yum clean all && \
rm -rf /tmp/* /var/tmp/*

启动 sshd

# /usr/sbin/sshd -D

这时报错

[root@672cee6ceca0 ~]# usr/sbin/sshd -D
bash: usr/sbin/sshd: No such file or directory
[root@672cee6ceca0 ~]# /usr/sbin/sshd -D
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key
sshd: no hostkeys available — exiting.

执行以下命令解决

# ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N ”
# ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ”
# ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N ”

修改 /etc/ssh/sshd_config
用 vi 改,或者 sed

UsePAM yes 改为 UsePAM no
UsePrivilegeSeparation sandbox 改为 UsePrivilegeSeparation no
# sed -i "s/#UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config
# sed -i "s/UsePAM.*/UsePAM no/g" /etc/ssh/sshd_config

修改容器 root 密码

passwd root
或者
echo "123456" | passwd –stdin root

发表评论

电子邮件地址不会被公开。 必填项已用*标注