From 0540421265e1d8d8c0d985d6496aef25ae664be2 Mon Sep 17 00:00:00 2001 From: Aaron Godfrey Date: Thu, 17 Jan 2019 20:23:11 -0800 Subject: [PATCH 1/6] Add optional ciphers for ssh config. --- remote-backup/config.json | 2 ++ remote-backup/run.sh | 2 ++ 2 files changed, 4 insertions(+) diff --git a/remote-backup/config.json b/remote-backup/config.json index c92d402..0c832e7 100644 --- a/remote-backup/config.json +++ b/remote-backup/config.json @@ -10,6 +10,7 @@ "hassio_role": "backup", "map": ["backup:rw"], "options": { + "ssh_cipher": "", "ssh_host": "", "ssh_port": 22, "ssh_user": "", @@ -19,6 +20,7 @@ "keep_local_backup": "" }, "schema": { + "ssh_cipher": "str", "ssh_host": "str", "ssh_port": "int", "ssh_user": "str", diff --git a/remote-backup/run.sh b/remote-backup/run.sh index dbd25b4..84c766e 100755 --- a/remote-backup/run.sh +++ b/remote-backup/run.sh @@ -4,6 +4,7 @@ set -e CONFIG_PATH=/data/options.json # parse inputs from options +SSH_CIPHER=$(jq --raw-output ".ssh_cipher" $CONFIG_PATH) SSH_HOST=$(jq --raw-output ".ssh_host" $CONFIG_PATH) SSH_PORT=$(jq --raw-output ".ssh_port" $CONFIG_PATH) SSH_USER=$(jq --raw-output ".ssh_user" $CONFIG_PATH) @@ -25,6 +26,7 @@ function add-ssh-key { echo " User ${SSH_USER}" echo " Port ${SSH_PORT}" echo " StrictHostKeyChecking no" + echo " Ciphers ${SSH_CIPHER}" ) > "${HOME}/.ssh/config" while read -r line; do From c024dbd4a5f40d5db1667303bfd156fc4abbf65b Mon Sep 17 00:00:00 2001 From: Aaron Godfrey Date: Thu, 17 Jan 2019 20:38:22 -0800 Subject: [PATCH 2/6] Echo config --- remote-backup/run.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/remote-backup/run.sh b/remote-backup/run.sh index 84c766e..7a63e72 100755 --- a/remote-backup/run.sh +++ b/remote-backup/run.sh @@ -32,7 +32,8 @@ function add-ssh-key { while read -r line; do echo "$line" >> ${HOME}/.ssh/id done <<< "$SSH_KEY" - + + echo "$(cat ~/.ssh/config)" chmod 600 "${HOME}/.ssh/config" chmod 600 "${HOME}/.ssh/id" } From cfd33a48435f575fcd7a4b5fa9f6192987143acc Mon Sep 17 00:00:00 2001 From: Aaron Godfrey Date: Thu, 17 Jan 2019 20:40:37 -0800 Subject: [PATCH 3/6] Reverting commit --- remote-backup/run.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/remote-backup/run.sh b/remote-backup/run.sh index 7a63e72..aeb33c7 100755 --- a/remote-backup/run.sh +++ b/remote-backup/run.sh @@ -33,7 +33,6 @@ function add-ssh-key { echo "$line" >> ${HOME}/.ssh/id done <<< "$SSH_KEY" - echo "$(cat ~/.ssh/config)" chmod 600 "${HOME}/.ssh/config" chmod 600 "${HOME}/.ssh/id" } From 826f51998d4c29a00a696e370a7e988d0308dc37 Mon Sep 17 00:00:00 2001 From: Aaron Godfrey Date: Thu, 17 Jan 2019 21:02:03 -0800 Subject: [PATCH 4/6] Only add ssh ciphers if something is defined. --- remote-backup/config.json | 4 ++-- remote-backup/run.sh | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/remote-backup/config.json b/remote-backup/config.json index 0c832e7..0bb80d9 100644 --- a/remote-backup/config.json +++ b/remote-backup/config.json @@ -10,7 +10,7 @@ "hassio_role": "backup", "map": ["backup:rw"], "options": { - "ssh_cipher": "", + "ssh_ciphers": "", "ssh_host": "", "ssh_port": 22, "ssh_user": "", @@ -20,7 +20,7 @@ "keep_local_backup": "" }, "schema": { - "ssh_cipher": "str", + "ssh_ciphers": "str", "ssh_host": "str", "ssh_port": "int", "ssh_user": "str", diff --git a/remote-backup/run.sh b/remote-backup/run.sh index aeb33c7..7543254 100755 --- a/remote-backup/run.sh +++ b/remote-backup/run.sh @@ -4,7 +4,7 @@ set -e CONFIG_PATH=/data/options.json # parse inputs from options -SSH_CIPHER=$(jq --raw-output ".ssh_cipher" $CONFIG_PATH) +SSH_CIPHERS=$(jq --raw-output ".ssh_ciphers" $CONFIG_PATH) SSH_HOST=$(jq --raw-output ".ssh_host" $CONFIG_PATH) SSH_PORT=$(jq --raw-output ".ssh_port" $CONFIG_PATH) SSH_USER=$(jq --raw-output ".ssh_user" $CONFIG_PATH) @@ -26,7 +26,9 @@ function add-ssh-key { echo " User ${SSH_USER}" echo " Port ${SSH_PORT}" echo " StrictHostKeyChecking no" - echo " Ciphers ${SSH_CIPHER}" + if [ -n "$SSH_CIPHERS" ]; then + echo " Ciphers ${SSH_CIPHER}" + fi ) > "${HOME}/.ssh/config" while read -r line; do From 339d87cd43c998c839fb6bfb14d3edf57978dc5d Mon Sep 17 00:00:00 2001 From: Aaron Godfrey Date: Thu, 17 Jan 2019 21:03:41 -0800 Subject: [PATCH 5/6] Remove space --- remote-backup/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote-backup/run.sh b/remote-backup/run.sh index 7543254..93b8ecf 100755 --- a/remote-backup/run.sh +++ b/remote-backup/run.sh @@ -34,7 +34,7 @@ function add-ssh-key { while read -r line; do echo "$line" >> ${HOME}/.ssh/id done <<< "$SSH_KEY" - + chmod 600 "${HOME}/.ssh/config" chmod 600 "${HOME}/.ssh/id" } From 6501d7748c410a6320903e5238dec3a8825dec2c Mon Sep 17 00:00:00 2001 From: Aaron Godfrey Date: Thu, 17 Jan 2019 21:14:52 -0800 Subject: [PATCH 6/6] Updated the docs. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index c740a01..ae6ffd5 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,7 @@ See my [repository of addons][hassio-addons] for more information. |`remote_directory`|Yes|The directory to put the backups on the remote server.| |`zip_password`|No|If set then the backup will be contained in a password protected zip| |`keep_local_backup`|No|Control how many local backups you want to preserve. Default (`""`) is to keep no local backups created from this addon. If `all` then all loocal backups will be preserved. A positive integer will determine how many of the latest backups will be preserved. Note this will delete other local backups created outside this addon. +|`ssh_ciphers`|No|Optional ciphers to use for `SCP`. e.g. `aes128-cbc,3des-cbc` This is useful if you need to connect to a machine running an old version of ssh server.| ## Example: daily backups at 4 AM