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

Add JENKINS_LOW_SECURITY_DOMAIN feature. #4

Open
wants to merge 5 commits into
base: 2.x
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
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ENV CONFD_OPTS '--backend=env --onetime'

# This contains the repo for docker
COPY root /
RUN mkdir -p /root/.ssh

RUN apt-get -y install \
apt-transport-https \
Expand Down Expand Up @@ -81,6 +82,9 @@ RUN install-plugins.sh \
workflow-multibranch:2.14 \
ws-cleanup:0.32

# Designate the default domains to limit strict key checking.
ENV OUTRIGGER_STRICT_HOST_CHECKING_DISABLED 'github.com bitbucket.org'

# Run the s6-based init.
ENTRYPOINT ["/init"]

Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,27 @@ configurations offered by this image.
You can pass this as an environment variable to container and it will customize the `admin`
user password. If this is not set, the `admin` user will have a blank password.

### OUTRIGGER_STRICT_HOST_CHECKING_DISABLED

Specify a domain for an SSH config file Host entry. This domain will have the SSH
settig `StrictHostKeyChecking` disabled. As a result, ssh or git commands from
the Jenkins container will not be challenged for a hosts key entry.

In keeping with SSH configuration syntax, you can use a single wildcard in your
host name and may also specify multiple host names delimited by a single space.

As long as you are using key-based authentication this represents a minimal risk
of exposure to Man-in-the-Middle attacks, for more details see:
http://www.gremwell.com/ssh-mitm-public-key-authentication

#### Default Value & Example

```
OUTRIGGER_STRICT_HOST_CHECKING_DISABLED="github.com bitbucket.org"
```

If you do not wish Github and Bitbucket to have StrictHostKeyChecking disabled,
set this environment variable to an empty string.

## Customization

Expand Down
6 changes: 6 additions & 0 deletions root/etc/confd/conf.d/ssh-config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[template]
src="ssh_config.tmpl"
dest="/root/.ssh/config"
keys=[
"/",
]
4 changes: 4 additions & 0 deletions root/etc/confd/templates/ssh_config.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{{if getenv "OUTRIGGER_STRICT_HOST_CHECKING_DISABLED"}}
Host {{getenv "OUTRIGGER_STRICT_HOST_CHECKING_DISABLED"}}
StrictHostKeyChecking no
{{end}}
9 changes: 2 additions & 7 deletions root/etc/cont-init.d/20-outrigger-private-key
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
KEY_BASE=/root/.ssh
KEY_FILE=$KEY_BASE/outrigger.key

if [ -e $KEY_FILE ]; then

if [ -e $KEY_FILE ] && [ ! -d $KEY_FILE ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would that be a directory?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mount a non existent file on your host with a volume mount an empty directory shows up on both sides.

then
echo "KEY_FILE found. Setting up key..."

else

echo "##############################################################"
Expand Down Expand Up @@ -34,7 +33,3 @@ fi
cp $KEY_FILE $PRIVATE_KEY
chown root:root $PRIVATE_KEY
chmod 600 $PRIVATE_KEY

# Make sure that commands don't need to prompt for host keys
ssh-keyscan -H bitbucket.org >> $KEY_BASE/known_hosts
ssh-keyscan -H github.com >> $KEY_BASE/known_hosts
4 changes: 0 additions & 4 deletions root/root/.ssh/config

This file was deleted.