<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[沧海一粟]]></title> 
<link>http://www.dzhope.com/index.php</link> 
<description><![CDATA[Web系统架构与服务器运维,php开发]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[沧海一粟]]></copyright>
<item>
<link>http://www.dzhope.com/post//</link>
<title><![CDATA[docker中centos7安装ssh服务]]></title> 
<author>jed &lt;jed521@163.com&gt;</author>
<category><![CDATA[服务器技术]]></category>
<pubDate>Mon, 24 May 2021 03:36:22 +0000</pubDate> 
<guid>http://www.dzhope.com/post//</guid> 
<description>
<![CDATA[ 
	容器中安装passwd,openssl,openssh-server<br/><div class="code"><br/>yum install passwd openssl openssh-server net-tools -y<br/></div><br/>安装完成后<br/>启动sshd:<br/><div class="code"><br/># /usr/sbin/sshd -D<br/></div><br/>这时报以下错误：<br/><div class="code"><br/>&#91;root@ b3426410ff43 /&#93;# /usr/sbin/sshd<br/>Could not load host key: /etc/ssh/ssh_host_rsa_key<br/>Could not load host key: /etc/ssh/ssh_host_ecdsa_key<br/>Could not load host key: /etc/ssh/ssh_host_ed25519_key<br/></div><br/>执行以下命令解决：<br/><div class="code"><br/>&#91;root@b3426410ff43 /&#93;# ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N &#039;&#039;<br/>&#91;root@b3426410ff43 /&#93;# ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N &#039;&#039;<br/>&#91;root@b3426410ff43 /&#93;# ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N &#039;&#039;<br/></div><br/>然后，修改 /etc/ssh/sshd_config 配置信息：<br/><div class="code"><br/>UsePAM yes 改为 UsePAM no<br/>UsePrivilegeSeparation sandbox 改为 UsePrivilegeSeparation no<br/></div><br/>可以用vi改，也可以用下面命令<br/><div class="code"><br/>&#91;root@b3426410ff43 /&#93;# sed -i &quot;s/#UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g&quot; /etc/ssh/sshd_config<br/>&#91;root@b3426410ff43 /&#93;# sed -i &quot;s/UsePAM.*/UsePAM no/g&quot; /etc/ssh/sshd_config<br/></div><br/>修改完后，重新启动sshd<br/><div class="code"><br/>&#91;root@b3426410ff43 /&#93;# /usr/sbin/sshd -D<br/></div><br/>然后修改root密码<br/><div class="code"><br/>passwd root<br/></div><br/>或者直接一句修改<br/><div class="code"><br/>echo “123456″ &#124; passwd --stdin root<br/></div><br/>接着需要把修改后的镜像保存了，首先输入exit退出容器，再使用下面命令查看刚运行过的，<br/>docker commit将修改后镜像保存到本地，参数是ID，名字<br/><div class="code"><br/>#docker ps -all<br/>CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES<br/>b3426410ff43 centos:7 &quot;/bin/bash&quot; 4 minutes ago Exited (0) 4 seconds ago centos7ssh<br/>#docker commit b5926410fe60 myimage/centos7-ssh<br/></div><br/>下次可以输入刚保存的名字启动修改过安装了ssh服务的镜像了。
]]>
</description>
</item><item>
<link>http://www.dzhope.com/post//#blogcomment</link>
<title><![CDATA[[评论] docker中centos7安装ssh服务]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>http://www.dzhope.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>