Skip to content

Instantly share code, notes, and snippets.

@StudioSpindle
Last active May 22, 2019 10:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StudioSpindle/d2d57643e4270beb6245fb88587dd37e to your computer and use it in GitHub Desktop.
Save StudioSpindle/d2d57643e4270beb6245fb88587dd37e to your computer and use it in GitHub Desktop.
Install and configure Git on CentOS
#!/bin/bash
# Important: This version has not been tested and used yet
# First check if you have root privileges
if [ id -u 0 ]
then echo "Please run as root"
exit
fi
# Prompt user for necessary input
read -p "Please enter your username: " USERNAME
read -p "Please enter your e-mail: " USEREMAIL
# Install Git
sudo yum -y install git
# Verify if it's installed
git --version
# stores user into the global configuration file: ~./gitconfig
git config --global user.name USERNAME
git config --global user.email USEREMAIL
# verify the config
echo "The following user has been created in the global config (~./gitconfig):"
git config --list
# then create SSH key (stored in ~/.ssh)
# TODO: make it accept the default location and passhphrase without prompting
ssh-keygen -q -t rsa -b 4096 -C USEREMAIL
# Add the SSH key to the SSH agent
eval "$(ssh-agent -s)"
# add the SSH private key to the SSH-agent
ssh-add -K ~/.ssh/id_rsa
# Show the pbulic RSA in the console
cat ~/.ssh/id_rsa.pub
# To be continued
# https://help.github.com/en/articles/adding-a-new-ssh-key-to-your-github-account
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment