Last active
May 22, 2019 10:34
-
-
Save StudioSpindle/d2d57643e4270beb6245fb88587dd37e to your computer and use it in GitHub Desktop.
Install and configure Git on CentOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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