Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding SSH support to DinV #2524

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions dinv/dch-photon-18.06/Dockerfile
Original file line number Diff line number Diff line change
@@ -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/
Expand All @@ -25,10 +25,17 @@ 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 \
git \
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/

Expand All @@ -43,11 +50,29 @@ FROM scratch

LABEL maintainer "[email protected]"

ENV TERM linux
ENV TERM=linux \
NOTVISIBLE="in users profile"

COPY --from=base /temp_chroot /

EXPOSE 2375 2376
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 && \
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
Expand Down
22 changes: 21 additions & 1 deletion dinv/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
}