2 # Licensed to the Apache Software Foundation (ASF) under one or more
3 # contributor license agreements. See the NOTICE file distributed with
4 # this work for additional information regarding copyright ownership.
5 # The ASF licenses this file to You under the Apache License, Version 2.0
6 # (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
18 # Image for use on Mac boxes to get a gpg agent socket available
19 # within transient release building ocntainers.
23 # docker build --build-arg "UID=$UID" --build-arg "RM_USER=$USER" \
24 # --tag org.apache.hbase/gpg-agent-proxy mac-sshd-gpg-agent
28 # docker run --rm -p 62222:22 \
29 # --mount "type=bind,src=${HOME}/.ssh/id_rsa.pub,dst=/home/${USER}/.ssh/authorized_keys,readonly" \
30 # --mount "type=volume,src=gpgagent,dst=/home/${USER}/.gnupg/" \
31 # org.apache.hbase/gpg-agent-proxy:latest
35 # ssh -p 62222 -R "/home/${USER}/.gnupg/S.gpg-agent:$(gpgconf --list-dir agent-extra-socket)" \
36 # -i "${HOME}/.ssh/id_rsa" -N -n localhost
38 # launch a docker container to do work that shares the mount for the gpg agent
39 # expressly does not need to be this same image, but needs to have defined the same user
41 # docker run --rm -it \
42 # --mount "type=volume,src=gpgagent,dst=/home/${USER}/.gnupg/" \
43 # --mount "type=bind,src=${HOME}/projects/hbase-releases/KEYS,dst=/home/${USER}/KEYS,readonly" \
44 # --entrypoint /bin/bash --user "${USER}" --workdir "/home/${USER}/" \
45 # org.apache.hbase/gpg-agent-proxy:latest
48 # Make sure to import the public keys
50 # gpg --no-autostart --import < ${HOME}/KEYS
52 # gpg --no-autostart --edit-key ${YOUR_KEY}
59 # gpg --no-autostart --armor --detach --sign foo
60 # gpg --no-autostart --verify foo.asc
63 # * gpg forwarding over ssh: https://wiki.gnupg.org/AgentForwarding
64 # * example docker for sshd: https://github.com/hotblac/nginx-ssh
65 # * why we have to bother with this: https://github.com/docker/for-mac/issues/483
67 # If the docker image changes then the host key used by sshd will change and you will get a
68 # nastygram when launching ssh about host identification changing. This is expected. you should
69 # remove the previous host key.
72 # * Docker Desktop 2.2.0.5
74 # * pinentry-mac 0.9.4
79 # This is all in a single "RUN" command so that if anything changes, "apt update" is run to fetch
80 # the most current package versions (instead of potentially using old versions cached by docker).
82 # We only need gnupg2 here if we want the ability to test out the gpg-agent forwarding by sshing
83 # into the container rather than launching a new docker container.
84 RUN DEBIAN_FRONTEND=noninteractive apt-get -qq -y update \
85 && DEBIAN_FRONTEND=noninteractive apt-get -qq -y install --no-install-recommends \
86 openssh-server=1:7.6p1-4ubuntu0.3 gnupg2=2.2.4-1ubuntu1.3 && mkdir /run/sshd \
87 && echo "StreamLocalBindUnlink yes" >> /etc/ssh/sshd_config \
89 && rm -rf /var/lib/apt/lists/*
94 RUN groupadd sshgroup && \
95 useradd --create-home --shell /bin/bash --groups sshgroup --uid $UID $RM_USER && \
96 mkdir /home/$RM_USER/.ssh /home/$RM_USER/.gnupg && \
97 chown -R $RM_USER:sshgroup /home/$RM_USER/ && \
98 chmod -R 700 /home/$RM_USER/
99 # When we run we run sshd
100 ENTRYPOINT ["/usr/sbin/sshd", "-D"]