From 2bc1c26af53a379d75d46d6c6fd20a04819ff643 Mon Sep 17 00:00:00 2001 From: arslanabbasi Date: Mon, 30 Sep 2019 16:07:36 -0700 Subject: [PATCH 1/2] Adding ssh support to DinV --- dinv/dch-photon-18.06/Dockerfile | 30 +++++++++++++++++++++++++++--- dinv/main.go | 22 +++++++++++++++++++++- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/dinv/dch-photon-18.06/Dockerfile b/dinv/dch-photon-18.06/Dockerfile index 26cad53c4e..3e7d60e270 100644 --- a/dinv/dch-photon-18.06/Dockerfile +++ b/dinv/dch-photon-18.06/Dockerfile @@ -1,5 +1,5 @@ # Build certgen in separate container -FROM golang:1.8 AS build-env +FROM golang:1.13.1 AS build-env # copy the non-version specific files first so version specific can overwrite ADD . /go/src/dinv ADD ./dch-photon-18.06/* /go/src/dinv/ @@ -25,10 +25,16 @@ RUN echo "> Installing photon base system in chroot, killing output to avoid off photon-repos-2.0-2.ph2 \ tdnf-1.2.3-4.ph2 \ docker-18.06.2-3.ph2 \ + openssh \ procps-ng-3.3.15-2.ph2 \ + sed \ + vim \ + nano \ iptables-1.6.1-4.ph2 > /dev/null 2>&1 +#RUN ls -al /etc/ RUN cp /etc/resolv.conf $TEMP_CHROOT/etc/ + RUN mkdir $TEMP_CHROOT/certs COPY --from=build-env /go/src/dinv/dinv $TEMP_CHROOT/ @@ -43,11 +49,29 @@ FROM scratch LABEL maintainer "fabio@vmware.com" -ENV TERM linux +ENV TERM=linux \ + NOTVISIBLE="in users profile" COPY --from=base /temp_chroot / -EXPOSE 2375 2376 +RUN echo -e VMware@12345\\\nVMware@12345\\\n|passwd && \ +sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \ +sed -i 's/PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config && \ +sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd && \ +echo "export VISIBLE=now" >> /etc/profile && \ +ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' && \ +ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' && \ +ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' && \ +ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N '' + +#RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config +#RUN sed -i 's/PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config +#RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd +ENV NOTVISIBLE "in users profile" +#RUN echo "export VISIBLE=now" >> /etc/profile +#RUN ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key -N '' && ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key -N '' && ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' && ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key -N '' + +EXPOSE 2375 2376 22 VOLUME /certs VOLUME /var/lib/docker diff --git a/dinv/main.go b/dinv/main.go index 58e4f2f04b..2b0dfbe303 100644 --- a/dinv/main.go +++ b/dinv/main.go @@ -49,11 +49,21 @@ func init() { flag.StringVar(&storage, "storage", "overlay2", "Storage driver to use") flag.StringVar(&insecureRegistry, "insecure-registry", "", "Enable insecure registry communication") flag.StringVar(&vicIP, "vic-ip", "", "Set IP for automatic certificate creation") -} +} func main() { flag.Parse() + // Starting the sshd Daemon + ssh_cmd := exec.Command("/sbin/sshd") + + ssh_cmd.Stdout = os.Stdout + ssh_cmd.Stderr = os.Stderr + + if err := ssh_cmd.Run(); err != nil { + log.Fatal(err) + } + if os.Getenv("DEBUG") != "" { log.Level = logrus.DebugLevel dockerArgs = append(dockerArgs, "--log-level", "debug") @@ -158,5 +168,15 @@ func main() { log.Fatal(err) } + // Starting the sshd Daemon + + /* ssh_cmd := exec.Command("/sbin/sshd") + + ssh_cmd.Stdout = os.Stdout + ssh_cmd.Stderr = os.Stderr + + if err := ssh_cmd.Run(); err != nil { + log.Fatal(err) + } */ os.Exit(0) } From 376c04e3d2e0be187b6d1daf539fc6f4a59db9dc Mon Sep 17 00:00:00 2001 From: arslanabbasi Date: Tue, 1 Oct 2019 16:10:23 -0700 Subject: [PATCH 2/2] Adding git and changing password to VMware1! --- dinv/dch-photon-18.06/Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dinv/dch-photon-18.06/Dockerfile b/dinv/dch-photon-18.06/Dockerfile index 3e7d60e270..0a698dfbae 100644 --- a/dinv/dch-photon-18.06/Dockerfile +++ b/dinv/dch-photon-18.06/Dockerfile @@ -30,6 +30,7 @@ RUN echo "> Installing photon base system in chroot, killing output to avoid off sed \ vim \ nano \ + git \ iptables-1.6.1-4.ph2 > /dev/null 2>&1 #RUN ls -al /etc/ @@ -54,7 +55,7 @@ ENV TERM=linux \ COPY --from=base /temp_chroot / -RUN echo -e VMware@12345\\\nVMware@12345\\\n|passwd && \ +RUN echo -e 'VMware1!\nVMware1!\n'|passwd && \ sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \ sed -i 's/PermitRootLogin no/PermitRootLogin yes/' /etc/ssh/sshd_config && \ sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd && \