You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DevOps-Bash-tools/github_get_user_ssh_public_...

30 lines
762 B
Bash

#!/usr/bin/env bash
#
# Author: Hari Sekhon
# Date: 2019-09-18
#
# https://github.com/harisekhon/devops-bash-tools
#
# License: see accompanying LICENSE file
#
# https://www.linkedin.com/in/harisekhon
#
# Fetches the GitHub user's public SSH key from the GitHub API
#
# Uses $GITHUB_USER or $USER as the expected GitHub user
set -euo pipefail
[ -n "${DEBUG:-}" ] && set -x
if [[ "$USER" =~ hari|sekhon ]]; then
GITHUB_USER="${GITHUB_USER:-harisekhon}"
else
GITHUB_USER="${GITHUB_USER:-$USER}"
fi
echo "# Fetching SSH Public Key(s) from GitHub for account: $GITHUB_USER" >&2
echo "#" >&2
# technically should use the GitHub API, see adjacent github_get_user_ssh_public_key_api.sh for that version
curl -sS "https://github.com/$GITHUB_USER.keys"