diff --git a/images/02-console/console.sh b/images/02-console/console.sh index fa522b9d..980a9efe 100755 --- a/images/02-console/console.sh +++ b/images/02-console/console.sh @@ -5,15 +5,19 @@ setup_ssh() { for i in rsa dsa ecdsa ed25519; do local output=/etc/ssh/ssh_host_${i}_key - if [ ! -e $output ]; then + if [ ! -s $output ]; then local saved="$(ros config get rancher.ssh.keys.${i})" local pub="$(ros config get rancher.ssh.keys.${i}-pub)" if [[ -n "$saved" && -n "$pub" ]]; then ( - umask 477 - echo "$saved" > ${output} - echo "$pub" > ${output}.pub + umask 077 + temp_file=$(mktemp) + echo "$saved" > ${temp_file} + mv ${temp_file} ${output} + temp_file=$(mktemp) + echo "$pub" > ${temp_file} + mv ${temp_file} ${output}.pub ) else ssh-keygen -f $output -N '' -t $i @@ -76,7 +80,7 @@ cat > /etc/respawn.conf << EOF /usr/sbin/sshd -D EOF -for i in ttyS{0..4} tty0 ttyAMA0; do +for i in ttyS{0..4} ttyAMA0; do if grep -q 'console='$i /proc/cmdline; then echo '/sbin/getty 115200' $i >> /etc/respawn.conf fi diff --git a/images/10-centosconsole/Dockerfile b/images/10-centosconsole/Dockerfile index 5323480f..f54d540e 100644 --- a/images/10-centosconsole/Dockerfile +++ b/images/10-centosconsole/Dockerfile @@ -1,7 +1,7 @@ FROM rancher/os-centosconsole-base # FROM amd64=centos:7 arm64=skip arm=armhfbuild/centos:7 RUN yum upgrade -y && \ - yum install -y iptables openssh-server rsync sudo vim less ca-certificates psmisc htop + yum install -y iptables openssh-server rsync sudo vim less ca-certificates psmisc htop procps-ng RUN rm -rf /etc/ssh/*key* RUN rm -fr /sbin/poweroff /sbin/shutdown /sbin/reboot /sbin/halt /usr/sbin/poweroff /usr/sbin/shutdown /usr/sbin/reboot /usr/sbin/halt RUN ln -s /sbin/agetty /sbin/getty diff --git a/images/10-fedoraconsole/Dockerfile b/images/10-fedoraconsole/Dockerfile index ec7e2648..de0783ab 100644 --- a/images/10-fedoraconsole/Dockerfile +++ b/images/10-fedoraconsole/Dockerfile @@ -1,7 +1,7 @@ FROM rancher/os-fedoraconsole-base # FROM amd64=fedora:23 arm64=rancher/aarch64-fedora:23 arm=armv7/armhf-fedora:23 RUN dnf upgrade -y && \ - dnf install -y iptables openssh-server rsync sudo vim less ca-certificates psmisc htop + dnf install -y iptables openssh-server rsync sudo vim less ca-certificates psmisc htop procps-ng RUN rm -rf /etc/ssh/*key* RUN rm -fr /sbin/poweroff /sbin/shutdown /sbin/reboot /sbin/halt /usr/sbin/poweroff /usr/sbin/shutdown /usr/sbin/reboot /usr/sbin/halt RUN ln -s /sbin/agetty /sbin/getty