Skip to content

Commit

Permalink
[#1214] Added script to find and load SSH keys.
Browse files Browse the repository at this point in the history
Also, unified `DREVOPS_<PREFIX>_SSH_FILE` variable name accross scripts.
  • Loading branch information
AlexSkrypnyk committed Mar 3, 2024
1 parent 1ec87d8 commit 7bd8b44
Show file tree
Hide file tree
Showing 13 changed files with 173 additions and 170 deletions.
64 changes: 38 additions & 26 deletions .drevops/docs/content/workflows/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -360,23 +360,21 @@ Default value: `curl`

Defined in: `.env`, `scripts/drevops/download-db.sh`

### `DREVOPS_DB_DOWNLOAD_SSH_FINGERPRINT`

The SSH key fingerprint.
### `DREVOPS_DB_DOWNLOAD_SSH_FILE`

If provided - the key will be looked-up and loaded into ssh client.
SSH key file used to access Lagoon environment to download the database.<br />Create an SSH key and add it to your account in the Lagoon Dashboard.

Default value: `UNDEFINED`
Default value: `HOME/.ssh/id_rsa`

Defined in: `scripts/drevops/download-db-lagoon.sh`
Defined in: `.env.local.default`, `scripts/drevops/download-db-lagoon.sh`

### `DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE`
### `DREVOPS_DB_DOWNLOAD_SSH_FINGERPRINT`

SSH key file used to access Lagoon environment to download the database.<br />Create an SSH key and add it to your account in the Lagoon Dashboard.
SSH key fingerprint used to connect to a remote.

Default value: `HOME/.ssh/id_rsa`
Default value: `UNDEFINED`

Defined in: `.env.local.default`, `scripts/drevops/download-db-lagoon.sh`
Defined in: `scripts/drevops/download-db-lagoon.sh`

### `DREVOPS_DB_EXPORT_DOCKER_ARCHIVE_FILE`

Expand Down Expand Up @@ -631,15 +629,15 @@ Default SSH file used if custom fingerprint is not provided.

Default value: `HOME/.ssh/id_rsa`

Defined in: `scripts/drevops/deploy-artifact.sh`, `scripts/drevops/deploy-lagoon.sh`
Defined in: `scripts/drevops/deploy-lagoon.sh`

### `DREVOPS_DEPLOY_SSH_FINGERPRINT`

SSH key fingerprint used to connect to remote.
SSH key fingerprint used to connect to remote. If not used, the currently<br />loaded default SSH key (the key used for code checkout) will be used or<br />deployment will fail with an error if the default SSH key is not loaded.<br />In most cases, the default SSH key does not work (because it is a read-only<br />key used by CircleCI to checkout code from git), so you should add another<br />deployment key.

Default value: `UNDEFINED`

Defined in: `scripts/drevops/deploy-artifact.sh`, `scripts/drevops/deploy-lagoon.sh`
Defined in: `scripts/drevops/deploy-lagoon.sh`

### `DREVOPS_DEPLOY_TYPES`

Expand Down Expand Up @@ -735,14 +733,6 @@ Default value: `UNDEFINED`

Defined in: `scripts/drevops/doctor.sh`

### `DREVOPS_DOCTOR_SSH_KEY_FILE`

Default SSH key file.

Default value: `HOME/.ssh/id_rsa`

Defined in: `scripts/drevops/doctor.sh`

### `DREVOPS_DRUPAL_CONFIG_PATH`

Path to configuration directory.
Expand Down Expand Up @@ -873,13 +863,15 @@ Defined in: `scripts/drevops/mirror-code.sh`

### `DREVOPS_MIRROR_CODE_SSH_FILE`

Default value: `DREVOPS_MIRROR_CODE_SSH_FINGERPRINT//:/`
Default SSH file used if custom fingerprint is not provided.

Default value: `UNDEFINED`

Defined in: `scripts/drevops/mirror-code.sh`

### `DREVOPS_MIRROR_CODE_SSH_FINGERPRINT`

Optional SSH key fingerprint to use for mirroring.
SSH key fingerprint used to connect to a remote.

Default value: `UNDEFINED`

Expand Down Expand Up @@ -1281,6 +1273,28 @@ Default value: `UNDEFINED`

Defined in: `scripts/drevops/info.sh`

### `DREVOPS_SSH_FILE`

Default SSH key file.

Default value: `HOME/.ssh/id_rsa`

Defined in: `scripts/drevops/doctor.sh`, `scripts/drevops/setup-ssh.sh`

### `DREVOPS_SSH_FINGERPRINT`

SSH key fingerprint used to load the key into an agent.<br />Used only if DREVOPS_[`${DREVOPS_SSH_PREFIX}`](#DREVOPS_SSH_PREFIX)_SSH_FINGERPRINT is not provided.

Default value: `UNDEFINED`

Defined in: `scripts/drevops/setup-ssh.sh`

### `DREVOPS_SSH_PREFIX`

Default value: `DEPLOY" ./scripts/drevops/setup-ssh.sh`

Defined in: `scripts/drevops/deploy-artifact.sh`, `scripts/drevops/mirror-code.sh`, `scripts/drevops/setup-ssh.sh`

### `DREVOPS_TASK_COPY_DB_ACQUIA_DST`

Destination environment name to copy DB to.
Expand Down Expand Up @@ -1499,9 +1513,7 @@ Defined in: `scripts/drevops/task-custom-lagoon.sh`

### `DREVOPS_TASK_SSH_FINGERPRINT`

SSH key fingerprint used to connect to remote.

If not used, the currently loaded default SSH key (the key used for code<br />checkout) will be used or deployment will fail with an error if the default<br />SSH key is not loaded.<br />In most cases, the default SSH key does not work (because it is a read-only<br />key used by CircleCI to checkout code from git), so you should add another<br />deployment key.
SSH key fingerprint used to connect to a remote.

Default value: `UNDEFINED`

Expand Down
4 changes: 2 additions & 2 deletions .drevops/tests/bats/_helper.bash
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ assert_files_present_provision_use_profile() {
assert_file_not_contains ".env.local.default" "DREVOPS_DB_DOWNLOAD_FTP_PASS"
assert_file_not_contains ".env.local.default" "DREVOPS_ACQUIA_KEY"
assert_file_not_contains ".env.local.default" "DREVOPS_ACQUIA_SECRET"
assert_file_not_contains ".env.local.default" "DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE"
assert_file_not_contains ".env.local.default" "DREVOPS_DB_DOWNLOAD_SSH_FILE"
assert_file_not_contains ".env.local.default" "DOCKER_USER"
assert_file_not_contains ".env.local.default" "DOCKER_PASS"

Expand Down Expand Up @@ -806,7 +806,7 @@ assert_files_present_no_integration_lagoon() {
assert_file_not_contains "docker-compose.yml" "lagoon.type: solr"
assert_file_not_contains "docker-compose.yml" "lagoon.type: none"

assert_file_not_contains ".env.local.default" "DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE="
assert_file_not_contains ".env.local.default" "DREVOPS_DB_DOWNLOAD_SSH_FILE="

popd >/dev/null || exit 1
}
Expand Down
14 changes: 7 additions & 7 deletions .drevops/tests/bats/fixtures/docker-compose.env_local.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"DREVOPS_DB_DOWNLOAD_FTP_PORT": "21",
"DREVOPS_DB_DOWNLOAD_FTP_USER": "",
"DREVOPS_DB_DOWNLOAD_SOURCE": "curl",
"DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_DOWNLOAD_SSH_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_FILE": "db.sql",
"DREVOPS_DEPLOY_TYPES": "artifact",
"DREVOPS_LAGOON_PRODUCTION_BRANCH": "main",
Expand Down Expand Up @@ -121,7 +121,7 @@
"DREVOPS_DB_DOWNLOAD_FTP_PORT": "21",
"DREVOPS_DB_DOWNLOAD_FTP_USER": "",
"DREVOPS_DB_DOWNLOAD_SOURCE": "curl",
"DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_DOWNLOAD_SSH_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_FILE": "db.sql",
"DREVOPS_DEPLOY_TYPES": "artifact",
"DREVOPS_LAGOON_PRODUCTION_BRANCH": "main",
Expand Down Expand Up @@ -203,7 +203,7 @@
"DREVOPS_DB_DOWNLOAD_FTP_PORT": "21",
"DREVOPS_DB_DOWNLOAD_FTP_USER": "",
"DREVOPS_DB_DOWNLOAD_SOURCE": "curl",
"DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_DOWNLOAD_SSH_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_FILE": "db.sql",
"DREVOPS_DEPLOY_TYPES": "artifact",
"DREVOPS_LAGOON_PRODUCTION_BRANCH": "main",
Expand Down Expand Up @@ -294,7 +294,7 @@
"DREVOPS_DB_DOWNLOAD_FTP_PORT": "21",
"DREVOPS_DB_DOWNLOAD_FTP_USER": "",
"DREVOPS_DB_DOWNLOAD_SOURCE": "curl",
"DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_DOWNLOAD_SSH_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_FILE": "db.sql",
"DREVOPS_DEPLOY_TYPES": "artifact",
"DREVOPS_LAGOON_PRODUCTION_BRANCH": "main",
Expand Down Expand Up @@ -382,7 +382,7 @@
"DREVOPS_DB_DOWNLOAD_FTP_PORT": "21",
"DREVOPS_DB_DOWNLOAD_FTP_USER": "",
"DREVOPS_DB_DOWNLOAD_SOURCE": "curl",
"DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_DOWNLOAD_SSH_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_FILE": "db.sql",
"DREVOPS_DEPLOY_TYPES": "artifact",
"DREVOPS_LAGOON_PRODUCTION_BRANCH": "main",
Expand Down Expand Up @@ -480,7 +480,7 @@
"DREVOPS_DB_DOWNLOAD_FTP_PORT": "21",
"DREVOPS_DB_DOWNLOAD_FTP_USER": "",
"DREVOPS_DB_DOWNLOAD_SOURCE": "curl",
"DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_DOWNLOAD_SSH_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_FILE": "db.sql",
"DREVOPS_DEPLOY_TYPES": "artifact",
"DREVOPS_LAGOON_PRODUCTION_BRANCH": "main",
Expand Down Expand Up @@ -588,7 +588,7 @@
"DREVOPS_DB_DOWNLOAD_FTP_PORT": "21",
"DREVOPS_DB_DOWNLOAD_FTP_USER": "",
"DREVOPS_DB_DOWNLOAD_SOURCE": "curl",
"DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_DOWNLOAD_SSH_FILE": "HOME/.ssh/id_rsa",
"DREVOPS_DB_FILE": "db.sql",
"DREVOPS_DEPLOY_TYPES": "artifact",
"DREVOPS_LAGOON_PRODUCTION_BRANCH": "main",
Expand Down
2 changes: 1 addition & 1 deletion .env.local.default
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ DREVOPS_ACQUIA_SECRET=

# SSH key file used to access Lagoon environment to download the database.
# Create an SSH key and add it to your account in the Lagoon Dashboard.
DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE=$HOME/.ssh/id_rsa
DREVOPS_DB_DOWNLOAD_SSH_FILE=$HOME/.ssh/id_rsa
#;> LAGOON
#;> !PROVISION_USE_PROFILE
#;< !PROVISION_USE_PROFILE
Expand Down
2 changes: 1 addition & 1 deletion .lagoon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ tasks:
command: |
if [ "$LAGOON_ENVIRONMENT_TYPE" != "production" ] && [ "$LAGOON_GIT_BRANCH" != "${DREVOPS_LAGOON_PRODUCTION_BRANCH:-main}" ]; then
# No need to load SSH file to access production DB as Lagoon has SSH agent keys.
export DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE=false
export DREVOPS_DB_DOWNLOAD_SSH_FILE=false
export DREVOPS_DB_DIR=/tmp/data
rm -Rf $DREVOPS_DB_DIR || true
./scripts/drevops/download-db.sh
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Use [Onboarding checklist](docs/onboarding.md) to track the project onboarding p
- Authenticate with Lagoon
1. Create an SSH key and add it to your account in the [Lagoon Dashboard](https://ui-lagoon-master.ch.amazee.io/).
2. Copy `.env.local.default` to `.env.local`.
3. Update `$DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE` environment variable in `.env.local` file
3. Update `$DREVOPS_DB_DOWNLOAD_SSH_FILE` environment variable in `.env.local` file
with the path to the SSH key.

[//]: # (#;> LAGOON)
Expand Down
23 changes: 1 addition & 22 deletions scripts/drevops/deploy-artifact.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,7 @@ info "Started ARTIFACT deployment."
[ "$(git config --global user.name)" = "" ] && note "Configuring global git user name." && git config --global user.name "${DREVOPS_DEPLOY_ARTIFACT_GIT_USER_NAME}"
[ "$(git config --global user.email)" = "" ] && note "Configuring global git user email." && git config --global user.email "${DREVOPS_DEPLOY_ARTIFACT_GIT_USER_EMAIL}"

# Use custom deploy key if fingerprint is provided.
if [ -n "${DREVOPS_DEPLOY_SSH_FINGERPRINT:-}" ]; then
note "Custom deployment key is provided."
DREVOPS_DEPLOY_SSH_FILE="${DREVOPS_DEPLOY_SSH_FINGERPRINT//:/}"
DREVOPS_DEPLOY_SSH_FILE="${HOME}/.ssh/id_rsa_${DREVOPS_DEPLOY_SSH_FILE//\"/}"
fi

[ ! -f "${DREVOPS_DEPLOY_SSH_FILE:-}" ] && fail "SSH key file ${DREVOPS_DEPLOY_SSH_FILE} does not exist." && exit 1

# LCOV_EXCL_START
if ssh-add -l | grep -q "${DREVOPS_DEPLOY_SSH_FILE}"; then
note "SSH agent has ${DREVOPS_DEPLOY_SSH_FILE} key loaded."
else
note "SSH agent does not have a required key loaded. Trying to load."
# Remove all other keys and add SSH key from provided fingerprint into SSH agent.
ssh-add -D >/dev/null
ssh-add "${DREVOPS_DEPLOY_SSH_FILE}"
fi
# LCOV_EXCL_STOP

# Disable strict host key checking in CI.
[ -n "${CI:-}" ] && mkdir -p "${HOME}/.ssh/" && echo -e "\nHost *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile /dev/null\n" >>"${HOME}/.ssh/config"
DREVOPS_SSH_PREFIX="DEPLOY" ./scripts/drevops/setup-ssh.sh

note "Installing artifact builder."
composer global require --dev -n --ansi --prefer-source --ignore-platform-reqs drevops/git-artifact:^0.5
Expand Down
39 changes: 2 additions & 37 deletions scripts/drevops/deploy-lagoon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,43 +83,8 @@ info "Started LAGOON deployment."
[ -z "${LAGOON_PROJECT}" ] && fail "Missing required value for LAGOON_PROJECT." && exit 1
{ [ -z "${DREVOPS_DEPLOY_BRANCH}" ] && [ -z "${DREVOPS_DEPLOY_PR}" ]; } && fail "Missing required value for DREVOPS_DEPLOY_BRANCH or DREVOPS_DEPLOY_PR." && exit 1

# Use custom deploy key if fingerprint is provided.
if [ -n "${DREVOPS_DEPLOY_SSH_FINGERPRINT}" ]; then
# Find the MD5 hash if the SSH_KEY_FINGERPRINT starts with SHA256.
if [ "${DREVOPS_DEPLOY_SSH_FINGERPRINT#SHA256:}" != "${DREVOPS_DEPLOY_SSH_FINGERPRINT}" ]; then
for file in "${HOME}"/.ssh/id_rsa*; do
calculated_sha256_fingerprint=$(ssh-keygen -l -E sha256 -f "${file}" | awk '{print $2}')
if [ "${calculated_sha256_fingerprint}" = "${DREVOPS_DEPLOY_SSH_FINGERPRINT}" ]; then
DREVOPS_DEPLOY_SSH_FINGERPRINT=$(ssh-keygen -l -E md5 -f "${file}" | awk '{print $2}')
DREVOPS_DEPLOY_SSH_FINGERPRINT="${DREVOPS_DEPLOY_SSH_FINGERPRINT#MD5:}"
break
fi
done
fi

# Cleanups the fingerprint and create a file name.
file="${DEPLOY_SSH_KEY_FINGERPRINT//:/}"
DREVOPS_DEPLOY_SSH_FILE="${HOME}/.ssh/id_rsa_${file//\"/}"
fi

[ ! -f "${DREVOPS_DEPLOY_SSH_FILE}" ] && fail "SSH key file ${DREVOPS_DEPLOY_SSH_FILE} does not exist." && exit 1

[ -z "${SSH_AGENT_PID:-}" ] && eval "$(ssh-agent)"

# LCOV_EXCL_START
if ssh-add -l | grep -q "${DREVOPS_DEPLOY_SSH_FILE}"; then
note "SSH agent has ${DREVOPS_DEPLOY_SSH_FILE} key loaded."
else
note "SSH agent does not have a required key loaded. Trying to load."
# Remove all other keys and add SSH key from provided fingerprint into SSH agent.
ssh-add -D >/dev/null
ssh-add "${DREVOPS_DEPLOY_SSH_FILE}"
ssh-add -l
fi
# LCOV_EXCL_STOP

# Disable strict host key checking in CI.
[ -n "${CI:-}" ] && mkdir -p "${HOME}/.ssh/" && echo -e "\nHost *\n\tStrictHostKeyChecking no\n\tUserKnownHostsFile /dev/null\n" >>"${HOME}/.ssh/config"
# Use SSH key loader to find the SSH key file.
DREVOPS_DEPLOY_SSH_FILE="$(DREVOPS_SSH_PREFIX="DEPLOY" ./scripts/drevops/setup-ssh.sh | grep 'Using SSH key file ' | cut -d ' ' -f 5 || false)"

if ! command -v lagoon >/dev/null || [ -n "${DREVOPS_DEPLOY_LAGOON_LAGOONCLI_FORCE_INSTALL}" ]; then
note "Installing Lagoon CLI."
Expand Down
4 changes: 2 additions & 2 deletions scripts/drevops/doctor.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ DREVOPS_DOCTOR_CHECK_WEBSERVER="${DREVOPS_DOCTOR_CHECK_WEBSERVER:-1}"
DREVOPS_DOCTOR_CHECK_BOOTSTRAP="${DREVOPS_DOCTOR_CHECK_BOOTSTRAP:-1}"

# Default SSH key file.
DREVOPS_DOCTOR_SSH_KEY_FILE="${DREVOPS_DOCTOR_SSH_KEY_FILE:-${HOME}/.ssh/id_rsa}"
DREVOPS_SSH_FILE="${DREVOPS_SSH_FILE:-${HOME}/.ssh/id_rsa}"

#-------------------------------------------------------------------------------

Expand Down Expand Up @@ -157,7 +157,7 @@ main() {
ssh_key_volume_mounted=0

# Check that the key is injected into pygmy ssh-agent container.
if ! pygmy status 2>&1 | grep -q "${DREVOPS_DOCTOR_SSH_KEY_FILE}"; then
if ! pygmy status 2>&1 | grep -q "${DREVOPS_SSH_FILE}"; then
warn "SSH key is not added to pygmy."
note "The SSH key will not be available in CLI container. Run 'pygmy restart' and then 'ahoy up'"
else
Expand Down
32 changes: 7 additions & 25 deletions scripts/drevops/download-db-lagoon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ DREVOPS_DB_DOWNLOAD_LAGOON_REMOTE_FILE="${DREVOPS_DB_DOWNLOAD_LAGOON_REMOTE_FILE
# does not exist.
DREVOPS_DB_DOWNLOAD_LAGOON_REMOTE_FILE_CLEANUP="${DREVOPS_DB_DOWNLOAD_LAGOON_REMOTE_FILE_CLEANUP:-db_*.sql}"

# The SSH key used to SSH into Lagoon.
DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE="${DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE:-}"

# The SSH key fingerprint.
#
# If provided - the key will be looked-up and loaded into ssh client.
# SSH key fingerprint used to connect to a remote.
DREVOPS_DB_DOWNLOAD_SSH_FINGERPRINT="${DREVOPS_DB_DOWNLOAD_SSH_FINGERPRINT:-}"

# Default SSH file used if custom fingerprint is not provided.
DREVOPS_DB_DOWNLOAD_SSH_FILE="${DREVOPS_DB_DOWNLOAD_SSH_FILE:-}"

# The SSH host of the Lagoon environment.
DREVOPS_DB_DOWNLOAD_LAGOON_SSH_HOST="${DREVOPS_DB_DOWNLOAD_LAGOON_SSH_HOST:-ssh.lagoon.amazeeio.cloud}"

Expand Down Expand Up @@ -88,31 +86,15 @@ if [ -f ".env.local" ]; then
t=$(mktemp) && export -p >"${t}" && set -a && . ".env.local" && set +a && . "${t}" && rm "${t}" && unset t
fi

# Discover and load a custom database dump key if fingerprint is provided.
if [ -n "${DREVOPS_DB_DOWNLOAD_SSH_FINGERPRINT:-}" ]; then
note "Custom database dump key is provided."
DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE="${DREVOPS_DB_DOWNLOAD_SSH_FINGERPRINT//:/}"
DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE="${HOME}/.ssh/id_rsa_${DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE//\"/}"

[ ! -f "${DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE}" ] && fail "SSH key file ${DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE} does not exist." && exit 1

if ssh-add -l | grep -q "${DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE}"; then
note "SSH agent has ${DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE} key loaded."
else
note "SSH agent does not have a required key loaded. Trying to load."
# Remove all other keys and add SSH key from provided fingerprint into SSH agent.
ssh-add -D >/dev/null
ssh-add "${DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE}"
fi
fi
DREVOPS_DB_DOWNLOAD_SSH_FILE="$(DREVOPS_SSH_PREFIX="DB_DOWNLOAD" ./scripts/drevops/setup-ssh.sh | grep 'Using SSH key file ' | cut -d ' ' -f 5 || false)"

ssh_opts=(-o "UserKnownHostsFile=/dev/null")
ssh_opts+=(-o "StrictHostKeyChecking=no")
ssh_opts+=(-o "LogLevel=error")
ssh_opts+=(-o "IdentitiesOnly=yes")
ssh_opts+=(-p "${DREVOPS_DB_DOWNLOAD_LAGOON_SSH_PORT}")
if [ "${DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE:-}" != false ]; then
ssh_opts+=(-i "${DREVOPS_DB_DOWNLOAD_SSH_KEY_FILE}")
if [ "${DREVOPS_DB_DOWNLOAD_SSH_FILE:-}" != false ]; then
ssh_opts+=(-i "${DREVOPS_DB_DOWNLOAD_SSH_FILE}")
fi

# Initiates an SSH connection to a remote server using provided SSH options.
Expand Down
Loading

0 comments on commit 7bd8b44

Please sign in to comment.