-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support to enable a ssh-server.
Signed-off-by: Hermann Mayer <[email protected]>
- Loading branch information
Showing
12 changed files
with
177 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
|
||
# We allow to start an SSH server inside the container to enable the | ||
# programmatically access to neo4j tooling. This is disabled by default. | ||
export SSHD_ENABLE=${SSHD_ENABLE:-'false'} | ||
export SSHD_CUSTOM_CONIFG=${SSHD_CUSTOM_CONIFG:-'false'} | ||
export SSHD_ROOT_PASSWORD=${SSHD_ROOT_PASSWORD:-'root'} | ||
|
||
# When this feature is disabled, we just do nothing. Forever. | ||
if [ "${SSHD_ENABLE}" != 'true' ]; then | ||
tail -f /dev/null | ||
exit $? | ||
fi | ||
|
||
# Prepare the environment for dbus | ||
mkdir -p /run/sshd | ||
chmod 0755 /run/sshd | ||
|
||
# We allow our users to supply a custom sshd config, | ||
# so we do not overwrite their file contents | ||
if [ "${SSHD_CUSTOM_CONIFG}" = 'false' ]; then | ||
cat >/etc/ssh/sshd_config <<'EOF' | ||
UsePAM no | ||
PermitRootLogin yes | ||
PasswordAuthentication yes | ||
ChallengeResponseAuthentication no | ||
PermitEmptyPasswords yes | ||
MaxAuthTries 20 | ||
StrictModes no | ||
EOF | ||
fi | ||
|
||
# Preserve the current environment variables for ssh sessions | ||
env | grep -P '(.+_|PATH)' | sed 's/^/export /g' >> /etc/environment | ||
echo 'source /etc/environment' >> /root/.bashrc | ||
|
||
# Change the root password to the configured one | ||
echo "root:${SSHD_ROOT_PASSWORD}" | chpasswd | ||
|
||
# Start the ssh daemon | ||
exec /usr/sbin/sshd -D -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[program:sshd] | ||
priority=10 | ||
startretries=20 | ||
directory=/tmp | ||
command=/usr/local/bin/sshd.sh | ||
user=root | ||
autostart=true | ||
autorestart=true | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
stopsignal=KILL | ||
stopwaitsecs=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
|
||
# We allow to start an SSH server inside the container to enable the | ||
# programmatically access to neo4j tooling. This is disabled by default. | ||
export SSHD_ENABLE=${SSHD_ENABLE:-'false'} | ||
export SSHD_CUSTOM_CONIFG=${SSHD_CUSTOM_CONIFG:-'false'} | ||
export SSHD_ROOT_PASSWORD=${SSHD_ROOT_PASSWORD:-'root'} | ||
|
||
# When this feature is disabled, we just do nothing. Forever. | ||
if [ "${SSHD_ENABLE}" != 'true' ]; then | ||
tail -f /dev/null | ||
exit $? | ||
fi | ||
|
||
# Prepare the environment for dbus | ||
mkdir -p /run/sshd | ||
chmod 0755 /run/sshd | ||
|
||
# We allow our users to supply a custom sshd config, | ||
# so we do not overwrite their file contents | ||
if [ "${SSHD_CUSTOM_CONIFG}" = 'false' ]; then | ||
cat >/etc/ssh/sshd_config <<'EOF' | ||
UsePAM no | ||
PermitRootLogin yes | ||
PasswordAuthentication yes | ||
ChallengeResponseAuthentication no | ||
PermitEmptyPasswords yes | ||
MaxAuthTries 20 | ||
StrictModes no | ||
EOF | ||
fi | ||
|
||
# Preserve the current environment variables for ssh sessions | ||
env | grep -P '(.+_|PATH)' | sed 's/^/export /g' >> /etc/environment | ||
echo 'source /etc/environment' >> /root/.bashrc | ||
|
||
# Change the root password to the configured one | ||
echo "root:${SSHD_ROOT_PASSWORD}" | chpasswd | ||
|
||
# Start the ssh daemon | ||
exec /usr/sbin/sshd -D -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[program:sshd] | ||
priority=10 | ||
startretries=20 | ||
directory=/tmp | ||
command=/usr/local/bin/sshd.sh | ||
user=root | ||
autostart=true | ||
autorestart=true | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
stopsignal=KILL | ||
stopwaitsecs=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env bash | ||
|
||
# We allow to start an SSH server inside the container to enable the | ||
# programmatically access to neo4j tooling. This is disabled by default. | ||
export SSHD_ENABLE=${SSHD_ENABLE:-'false'} | ||
export SSHD_CUSTOM_CONIFG=${SSHD_CUSTOM_CONIFG:-'false'} | ||
export SSHD_ROOT_PASSWORD=${SSHD_ROOT_PASSWORD:-'root'} | ||
|
||
# When this feature is disabled, we just do nothing. Forever. | ||
if [ "${SSHD_ENABLE}" != 'true' ]; then | ||
tail -f /dev/null | ||
exit $? | ||
fi | ||
|
||
# Prepare the environment for dbus | ||
mkdir -p /run/sshd | ||
chmod 0755 /run/sshd | ||
|
||
# We allow our users to supply a custom sshd config, | ||
# so we do not overwrite their file contents | ||
if [ "${SSHD_CUSTOM_CONIFG}" = 'false' ]; then | ||
cat >/etc/ssh/sshd_config <<'EOF' | ||
UsePAM no | ||
PermitRootLogin yes | ||
PasswordAuthentication yes | ||
ChallengeResponseAuthentication no | ||
PermitEmptyPasswords yes | ||
MaxAuthTries 20 | ||
StrictModes no | ||
EOF | ||
fi | ||
|
||
# Preserve the current environment variables for ssh sessions | ||
env | grep -P '(.+_|PATH)' | sed 's/^/export /g' >> /etc/environment | ||
echo 'source /etc/environment' >> /root/.bashrc | ||
|
||
# Change the root password to the configured one | ||
echo "root:${SSHD_ROOT_PASSWORD}" | chpasswd | ||
|
||
# Start the ssh daemon | ||
exec /usr/sbin/sshd -D -e |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[program:sshd] | ||
priority=10 | ||
startretries=20 | ||
directory=/tmp | ||
command=/usr/local/bin/sshd.sh | ||
user=root | ||
autostart=true | ||
autorestart=true | ||
stdout_logfile=/dev/stdout | ||
stdout_logfile_maxbytes=0 | ||
stderr_logfile=/dev/stderr | ||
stderr_logfile_maxbytes=0 | ||
stopsignal=KILL | ||
stopwaitsecs=1 |