-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into 182-add-local-path
- Loading branch information
Showing
25 changed files
with
533 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ node_modules | |
/.eslintcache | ||
/tests/data/json_docs | ||
/deploy/cht_sync/values.yaml | ||
/bastion/authorized_keys |
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,31 @@ | ||
# NOSONAR for "don't run docker images as root" - because sshd requires root https://superuser.com/a/1548482 :( | ||
# Deep link to Sonar "safe": https://sonarcloud.io/project/security_hotspots?status=SAFE&pullRequest=177&id=medic_cht-sync&tab=activity | ||
|
||
FROM alpine:3.20 | ||
|
||
ARG HOME=/var/lib/bastion | ||
|
||
ARG USER=bastion | ||
ARG GROUP=bastion | ||
ARG UID=4096 | ||
ARG GID=4096 | ||
|
||
ENV HOST_KEYS_PATH_PREFIX="/usr" | ||
ENV HOST_KEYS_PATH="${HOST_KEYS_PATH_PREFIX}/etc/ssh" | ||
|
||
COPY bastion /usr/sbin/bastion | ||
|
||
RUN addgroup -S -g ${GID} ${GROUP} \ | ||
&& adduser -D -h ${HOME} -s /bin/false -g "${USER} service" \ | ||
-u ${UID} -G ${GROUP} ${USER} \ | ||
&& sed -i "s/${USER}:!/${USER}:*/g" /etc/shadow \ | ||
&& set -x \ | ||
&& apk add --no-cache openssh-server curl \ | ||
&& echo -e "\nLogin Successful! \n\nHowever, interactive sessions not allowed. Use \"-N\" with ssh tunnel command instead: \n" > /etc/motd \ | ||
&& echo -e "\tssh -N -L 5432:CONTAINER-NAME:5432 bastion@PUBLIC-IP-OR-DNS -p 22222\n" >> /etc/motd \ | ||
&& chmod +x /usr/sbin/bastion \ | ||
&& mkdir -p ${HOST_KEYS_PATH} \ | ||
&& mkdir /etc/ssh/auth_principals \ | ||
&& echo "bastion" > /etc/ssh/auth_principals/bastion | ||
|
||
ENTRYPOINT ["bastion"] |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Mark | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,9 @@ | ||
This project hard forked from [docker-bastion](https://github.com/binlab/docker-bastion/tree/master) at version [1.2.0](https://github.com/binlab/docker-bastion/releases/tag/v1.2.0) | ||
|
||
Per MIT license, copyright of this `bastion` sub-directory is Mark/binlab/mark.binlab@gmail.com and MIT license file persists. | ||
|
||
Sample SSH tunnel to connect to container called `cht-sync-postgres-1` on remote server with IP `44.33.22.11`: | ||
|
||
```shell | ||
ssh -N -L 5432:cht-sync-postgres-1:5432 bastion@44.33.22.11 -p 22222 | ||
``` |
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 @@ | ||
# add external users' keys here |
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,52 @@ | ||
#!/usr/bin/env sh | ||
|
||
HOST_KEYS_PATH_PREFIX="${HOST_KEYS_PATH_PREFIX:='/'}" | ||
HOST_KEYS_PATH="${HOST_KEYS_PATH:='/etc/ssh'}" | ||
|
||
if [ -n "$TRUSTED_USER_CA_KEYS" ]; then | ||
CONFIG_TRUSTED_USER_CA_KEYS="-o TrustedUserCAKeys=$TRUSTED_USER_CA_KEYS" | ||
CONFIG_AUTHORIZED_PRINCIPALS_FILE="-o AuthorizedPrincipalsFile=/etc/ssh/auth_principals/%u" | ||
fi | ||
|
||
if [ ! -f "$HOST_KEYS_PATH/ssh_host_rsa_key" ]; then | ||
/usr/bin/ssh-keygen -A -f "$HOST_KEYS_PATH_PREFIX" | ||
fi | ||
|
||
if [ -n "$LISTEN_ADDRESS" ]; then | ||
CONFIG_LISTEN_ADDRESS="-o ListenAddress=$LISTEN_ADDRESS" | ||
else | ||
CONFIG_LISTEN_ADDRESS="-o ListenAddress=0.0.0.0" | ||
fi | ||
|
||
if [ -n "$LISTEN_PORT" ]; then | ||
CONFIG_LISTEN_PORT="-o Port=$LISTEN_PORT" | ||
else | ||
CONFIG_LISTEN_PORT="-o Port=22" | ||
fi | ||
|
||
# todo - original project has this as "assumes your authorized_keys file with 644 permissions | ||
# and mounted under /var/lib/bastion/authorized_keys." - but this simply doesn't work | ||
# without this hack | ||
cp /var/lib/bastion/authorized_keys-tmp /var/lib/bastion/authorized_keys | ||
chown bastion /var/lib/bastion/authorized_keys | ||
chmod 600 /var/lib/bastion/authorized_keys | ||
|
||
/usr/sbin/sshd -D -e -4 \ | ||
-o "HostKey=$HOST_KEYS_PATH/ssh_host_rsa_key" \ | ||
-o "HostKey=$HOST_KEYS_PATH/ssh_host_ecdsa_key" \ | ||
-o "HostKey=$HOST_KEYS_PATH/ssh_host_ed25519_key" \ | ||
-o "PasswordAuthentication=no" \ | ||
-o "PermitEmptyPasswords=no" \ | ||
-o "PermitRootLogin=no" \ | ||
-o "X11Forwarding=no" \ | ||
-o "AllowAgentForwarding=yes" \ | ||
-o "GatewayPorts=yes" \ | ||
-o "PermitTunnel=yes" \ | ||
-o "PubkeyAuthentication=yes" \ | ||
-o "AllowTcpForwarding=yes" \ | ||
-o "AuthorizedKeysFile=/var/lib/bastion/authorized_keys" \ | ||
-o "AuthorizedKeysCommandUser=nobody" \ | ||
$CONFIG_TRUSTED_USER_CA_KEYS \ | ||
$CONFIG_AUTHORIZED_PRINCIPALS_FILE \ | ||
$CONFIG_LISTEN_ADDRESS \ | ||
$CONFIG_LISTEN_PORT |
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
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,12 @@ | ||
services: | ||
bastion: | ||
build: ./bastion/ | ||
restart: unless-stopped | ||
ports: | ||
- ${BASTION_PORT:-22222}:22/tcp | ||
volumes: | ||
- ${BASTION_AUTHORIZED_KEYS_FILE:-$PWD/bastion/authorized_keys}:/var/lib/bastion/authorized_keys-tmp | ||
- bastion:/usr/etc/ssh:rw | ||
|
||
volumes: | ||
bastion: |
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 |
---|---|---|
@@ -1,11 +1,12 @@ | ||
version: '3.7' | ||
|
||
services: | ||
couchdb: | ||
image: public.ecr.aws/medic/cht-couchdb:4.8.0 | ||
image: public.ecr.aws/medic/cht-couchdb:4.15.0 | ||
restart: always | ||
ports: | ||
- "5984:5984" | ||
environment: | ||
- COUCHDB_USER=${COUCHDB_USER} | ||
- COUCHDB_PASSWORD=${COUCHDB_PASSWORD} | ||
- COUCHDB_SECRET=9c0d6034-0f19-45df-8fcd-5fec9c473c73 | ||
- COUCHDB_UUID=4c6bffc8-a5ac-4f98-a34c-6fb0e63964e5 | ||
- SVC_NAME=couchdb |
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,13 @@ | ||
services: | ||
postgres: | ||
ports: | ||
- 5432:${POSTGRES_PORT:-5432} | ||
|
||
pgadmin: | ||
image: dpage/pgadmin4 | ||
environment: | ||
PGADMIN_DEFAULT_EMAIL: ${PGADMIN_DEFAULT_EMAIL:-pgadmin4@pgadmin.org} | ||
PGADMIN_DEFAULT_PASSWORD: ${PGADMIN_DEFAULT_PASSWORD:-admin} | ||
PGADMIN_CONFIG_SERVER_MODE: 'False' | ||
ports: | ||
- "${PGADMIN_PORT:-5050}:80" |
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
Oops, something went wrong.