0

After setting up an ssh-deploy key for GitHub repository , I'm experiencing some difficulties in safely checking whether that ssh-key indeed has push access to that repository. To do so, I have written the method:

safely_check_if_ssh_deploy_key_can_push() {
    # Try to manually verify ssh deploy key works:
    local output=$(ssh -T git@github.com)
    
    echo "output=$output"
    expected_output="Hi $GITHUB_USER/$GITHUB_REPO! You've successfully authenticated, but GitHub does not provide shell access."
    if [ "$output" == "$expected_output" ]; then
        echo "FOUND"
    else
        echo "NOTFOUND"
    fi
}

However, the $output variable is empty. The output is:

Hi github_user/github_repository! You've successfully authenticated, but GitHub does not provide shell access. output=

Hence, I was wondering: how can one safely check if a GitHub ssh-deploy key has push access to a particular repository, using bash?

a.t.
  • 1,411
  • 1
  • 15
  • 49

0 Answers0