我在使用acbuild run时遇到了意外的行为。为了适应rkt,我们的想法是从一个运行CentOS7主机的基于SSH的容器开始。下面引用为centos7.aci的裸CentOS 7容器是使用给定的here说明在最新的CentOS7安装上创建的。用于构建SSHd ACI的脚本为
#! /bin/bash
acbuild begin ./centos7.aci
acbuild run -- yum install -y openssh-server
acbuild run -- mkdir /var/run/sshd
acbuild run -- sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
acbuild run -- sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
acbuild run -- ssh-keygen -A -C "" -N "" -q
acbuild run -- echo 'root:screencast' | chpasswd
acbuild set-name centos7-sshd
acbuild set-exec -- /usr/sbin/sshd -D
acbuild port add ssh tcp 22
acbuild write --overwrite centos7-sshd.aci
acbuild end当使用rkt run --insecure-options=image ./centos7-sshd.aci启动时,服务器会运行,但是连接尝试会失败,因为密码不被接受。如果我使用rkt enter进入正在运行的容器,并在里面重新运行echo 'root:screencast' | chpasswd,我就可以登录。因此,由于某些原因,acbuild运行指令不起作用...为了测试更多,我将其替换为acbuild run -- mkdir ~/.ssh acbuild run -- echo "<rkt host SSH public key>“ >> ~/.ssh/authorized_keys
启用基于密钥的登录而不是密码登录。它不起作用:密钥被拒绝。只要仔细查看容器,就会发现原因很明显:~/.ssh/中没有authorized_keys文件。如果我添加一个
acbuild run -- touch ~/.ssh/authorized_keys指令在尝试追加密钥之前,文件已创建,但仍为空。因此,在没有错误通知的情况下,acbuild run指令仍然不起作用。这可能与两个“忽略”指令都使用像>>和|这样的运算符有关吗?我看到的示例中显示的所有命令都没有使用任何这样的运算符,但是docs没有提到任何东西,在谷歌上搜索也没有帮助。在dockerfile RUN指令中,它们也工作得很好...这里出了什么问题?
附言:我尝试使用chroot而不是默认的systemd-nspawn引擎在“忽略”acbuild run指令中=>相同的结果
附注: StackOverflow上还没有acbuild标签,所以我不得不把它标记为rkt --有足够声誉的人可以创建一个吗?Thx
发布于 2017-08-14 22:02:57
好的,我知道使用acbuild run --debug选项会发生什么。什么时候
acbuild run -- echo 'root:screencast' | chpasswd
它返回Running: [echo root:screencast],则管道在主机上执行。为了得到预期的结果,它应该是
acbuild run -- /bin/sh -c "echo 'root:screencast' | chpasswd"
或以通用形式
acbuild run -- /bin/sh -c "<cmd with pipes>"
正如here所解释的那样
https://stackoverflow.com/questions/45674686
复制相似问题