From 17576219dc1f1079d68262d376b966f3c2fe4d97 Mon Sep 17 00:00:00 2001 From: Rubens Panfili Date: Tue, 6 Feb 2018 14:06:56 +0100 Subject: [PATCH] GitPull: add support for ssh cloned GitHub repositories (#241) * disabled StrictHostKeyChecking during ssh key validation * adds support to (ssh cloned) github repositories on key validation * update Changelog and config.json --- git_pull/CHANGELOG.md | 3 +++ git_pull/config.json | 2 +- git_pull/run.sh | 8 ++++---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/git_pull/CHANGELOG.md b/git_pull/CHANGELOG.md index 9e1557f..879e294 100644 --- a/git_pull/CHANGELOG.md +++ b/git_pull/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 4.1 +- Add support for key validation against ssh cloned GitHub repositories + ## 4.0 - Allow to use user/password authentication for GIT - New options `deployment_user` and `deployment_password` diff --git a/git_pull/config.json b/git_pull/config.json index 7e50fe2..165e2e9 100644 --- a/git_pull/config.json +++ b/git_pull/config.json @@ -1,6 +1,6 @@ { "name": "Git pull", - "version": "4.0", + "version": "4.1", "slug": "git_pull", "description": "Simple git pull to update the local configuration", "url": "https://home-assistant.io/addons/git_pull/", diff --git a/git_pull/run.sh b/git_pull/run.sh index 9deb174..d710121 100644 --- a/git_pull/run.sh +++ b/git_pull/run.sh @@ -60,11 +60,11 @@ if [ -n "$DEPLOYMENT_KEY" ]; then echo "Check SSH connection" IFS=':' read -ra GIT_URL_PARTS <<< "$REPOSITORY" # shellcheck disable=SC2029 - if ! ssh -T -o "BatchMode=yes" "${GIT_URL_PARTS[0]}" - then - echo "Valid SSH connection for ${GIT_URL_PARTS[0]}" + DOMAIN="${GIT_URL_PARTS[0]}" + if OUTPUT_CHECK=$(ssh -T -o "StrictHostKeyChecking=no" -o "BatchMode=yes" "$DOMAIN" 2>&1) || ([[ $DOMAIN = *"@github.com"* ]] && [[ $OUTPUT_CHECK = *"You've successfully authenticated"* ]]); then + echo "Valid SSH connection for $DOMAIN" else - echo "No valid SSH connection for ${GIT_URL_PARTS[0]}" + echo "No valid SSH connection for $DOMAIN" add-ssh-key fi fi