Installing & Configuring Git, Github on AWS EC2 instance along with SSH Authentication
Prerequisites:
An active AWS account with an EC2 instance running (preferably Amazon Linux 2).
Access credentials for your EC2 instance (SSH key pair or login details).
An SSH client like PuTTY, MobaXterm, or the built-in terminal on your local machine.
Steps:
Connect to your EC2 instance:
Open your preferred SSH client and establish a connection to your EC2 instance. Use the public IP address, username, and private key file (or password) associated with your instance.
Update your package lists:
Before installing Git, update the package lists to ensure you have the latest information:
sudo yum update -y
Install Git:
Use the appropriate package manager command based on your EC2 instance's operating system:
For Amazon Linux 2:
sudo yum install git -y
For Ubuntu/Debian:
sudo apt-get update -y
sudo apt-get install git -y
Verify the installation:
Check if Git is installed correctly by running:
git --version
Configure Git (optional):
git config --global user.name "Your Name"
git config --global user.email "emailaddress@domain.com"
Set up ssh on a computer.
Verify the existence of SSH key files. If the files ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub are not present, generate a new public/private key pair using the following command in a terminal or shell:
ssh-keygen -t rsa -C "emailaddress@email.com"
Obtain the contents of the id_rsa.pub file and store them in your system's clipboard for transfer.
Paste your ssh public key into your GitHub account settings.
Go to your GitHub Account Settings
Select SSH and GPG keys on the left.
Click “New SSH Key” on the right.
Add a title and paste the public key into the text box.
In a terminal/shell, type the following to test it:
ssh -T git@github.com