From b34b7cfcea93381b3f67c313b639494404e14d61 Mon Sep 17 00:00:00 2001 From: TadahiroYamamura Date: Wed, 4 Aug 2021 17:37:30 +0900 Subject: [PATCH 1/4] write ssh options in .ssh/config --- entrypoint.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 2806743..8666cde 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -8,5 +8,13 @@ mkdir -p "$SSH_PATH" echo "$SSH_PRIVATE_KEY" > "$SSH_PATH/deploy_key" chmod 600 "$SSH_PATH/deploy_key" +# Create SSH config file +touch "$SSH_PATH/config" +echo "Host rsync_target" >> "$SSH_PATH/config" +echo " HostName $SSH_HOSTNAME" >> "$SSH_PATH/config" +echo " User $SSH_USERNAME" >> "$SSH_PATH/config" +echo " IdentityFile $SSH_PATH/deploy_key" >> "$SSH_PATH/config" +echo " StrictHostKeyChecking no" >> "$SSH_PATH/config" + # Do deployment -sh -c "rsync ${INPUT_RSYNC_OPTIONS} -e 'ssh -i $SSH_PATH/deploy_key -o StrictHostKeyChecking=no' ${GITHUB_WORKSPACE}${INPUT_RSYNC_SOURCE} ${SSH_USERNAME}@${SSH_HOSTNAME}:${INPUT_RSYNC_TARGET}" +sh -c "rsync ${INPUT_RSYNC_OPTIONS} ${GITHUB_WORKSPACE}${INPUT_RSYNC_SOURCE} rsync_target:${INPUT_RSYNC_TARGET}" From 11f9c0660c6e194a0dbda8622c73c15092336723 Mon Sep 17 00:00:00 2001 From: TadahiroYamamura Date: Wed, 4 Aug 2021 17:38:48 +0900 Subject: [PATCH 2/4] append SSH_PORT option (default: 22) --- entrypoint.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/entrypoint.sh b/entrypoint.sh index 8666cde..4bcbc21 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -14,6 +14,7 @@ echo "Host rsync_target" >> "$SSH_PATH/config" echo " HostName $SSH_HOSTNAME" >> "$SSH_PATH/config" echo " User $SSH_USERNAME" >> "$SSH_PATH/config" echo " IdentityFile $SSH_PATH/deploy_key" >> "$SSH_PATH/config" +echo " Port ${SSH_PORT:-22}" >> "$SSH_PATH/config" echo " StrictHostKeyChecking no" >> "$SSH_PATH/config" # Do deployment From 1aeb9905b2501fdbbbd48bcc29b43e460f2593c4 Mon Sep 17 00:00:00 2001 From: TadahiroYamamura Date: Thu, 5 Aug 2021 12:53:16 +0900 Subject: [PATCH 3/4] specify the config file with option --- entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index 4bcbc21..d55a996 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -18,4 +18,4 @@ echo " Port ${SSH_PORT:-22}" >> "$SSH_PATH/config" echo " StrictHostKeyChecking no" >> "$SSH_PATH/config" # Do deployment -sh -c "rsync ${INPUT_RSYNC_OPTIONS} ${GITHUB_WORKSPACE}${INPUT_RSYNC_SOURCE} rsync_target:${INPUT_RSYNC_TARGET}" +sh -c "rsync -e 'ssh -F \"$SSH_PATH/config\"' ${INPUT_RSYNC_OPTIONS} ${GITHUB_WORKSPACE}${INPUT_RSYNC_SOURCE} rsync_target:${INPUT_RSYNC_TARGET}" From 110287732a2351bd120782a54486aafc51ef143f Mon Sep 17 00:00:00 2001 From: TadahiroYamamura Date: Thu, 5 Aug 2021 13:15:27 +0900 Subject: [PATCH 4/4] append a description of the SSH_PORT to document --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ef2b72c..5f1b54c 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Rsync files from a GitHub repo to a destination server over SSH | `SSH_PRIVATE_KEY` | The private key part of an SSH key pair. The public key part should be added to the `authorized_keys` on the destination server. | | `SSH_USERNAME` | The username to use when connecting to the destination server | | `SSH_HOSTNAME` | The hostname of the destination server | +| `SSH_PORT` | The port number of the destination server (default: 22) | ## Required arguments