GREEN='\033[0;32m'
NC='\033[0m'

AUTHORIZED_KEYS_PATH="${HOME}/.ssh/authorized_keys"

echo -e "${GREEN}This script pulls SSH public keys from Github and places them in your ${AUTHORIZED_KEYS_PATH} file${NC}"

read -p "Please provide your github username: " github_username

URL="https://github.com/${github_username}.keys"


curl $URL >> "${AUTHORIZED_KEYS_PATH}.new"

if [[ -f $AUTHORIZED_KEYS_PATH ]]; then
    cp "${AUTHORIZED_KEYS_PATH}" "${AUTHORIZED_KEYS_PATH}.old"
else
    touch "${AUTHORIZED_KEYS_PATH}"
fi

cat "${AUTHORIZED_KEYS_PATH}.new" >> "${AUTHORIZED_KEYS_PATH}"