Connecting Ubuntu with GitHub (AWS/Azure/GCP)
Tags: ubuntu, github, development, webdev
Published: 2023-08-19 07:25:04

Hello everyone, in this blog, we are gonna learn something pretty basic connectivity which is required in an Ubuntu (20.04) machine whether it is hosted on AWS, Azure, GCP, your laptop or you are running it in VM or container within your machine.

_PS. For cloud solutions, make sure that the outgoing port 22 is open in your security group for your machine._


# Shorter Route 

If you don't want to read the whole thing just do this:

Hit these commands:
```
sudo apt-get install git

git config --global user.name "Shameel Uddin"
git config --global user.email "shameel.uddin@ehasabtech.com"

ssh-keygen -t ed25519 -C "shameel.uddin@ehasabtech.com"

ssh-add ~/.ssh/id_ed25519

```
Add Key to your GitHub
https://github.com/settings/keys
then do this: 
```
ssh -T git@github.com 
```

# Longer Route. Moving forward...

## Installing Git
Install Git in your machine if it is not already installed.
```
sudo apt-get install git
```
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ec3vzrdvgzulim3l13ub.png)



## Do some basic Git configuration
Configure your username and email.
```
git config --global user.name "Shameel Uddin"
git config --global user.email "shameel.uddin@ehasabtech.com"
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oouc5mf1rqz6zh98tz1s.png)

## Starting SSH-Agent
```
eval "$(ssh-agent -s)"
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mmbkrqrcml0bf9t60sty.png)


## Generate the Key

```
ssh-keygen -t ed25519 -C "shameel.uddin@hasabtech.com"
```
This command will ask you where you want to keep it saved. You can keep it to default location which is up to you, it might be better if you don't as anyone would know where they are considering someone gain access to the machine.
Anyways, it further ask for passphrase. Give passphrase and move forward.
For simplicity, I am keeping it to default location with no passphrase.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tdsgrgs6trmebqx3gq8k.png)

## Add key to SSH Agent

```
ssh-add ~/.ssh/id_ed25519
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hv6ze4a3tbqx4g8pmw3f.png)

## Copy your public key
```
cat ~/.ssh/id_ed25519.pub
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2y7blwq6cxl0vdxavsur.png)

## Add it to GitHub

Go to this link:
```
https://github.com/settings/keys
```
Click on **New SSH Key**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eta0v11io7w1qu36ewps.png)

Add it as **Authentication Key**. Give Name and the key you copied from last step.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c9mq4ex6ud4ipi3q4wuj.png)

After being added, the page should appear like this:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cj80etnv86g2ttqs6uxl.png)


## Check Connectivity:
You can check connectivity like this:

```
ssh -T git@github.com 
```

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0z6oqiyg8ke81u72hlwx.png)

## Cloning Project

I made a mistake of cloning from HTTPS so please do not make this mistake and clone from SSH as mentioned below =)


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qmy5gls9rs9vknbq4ijy.png)


It's done 🥳

Thank you for reading!

Follow me here:
LinkedIn: https://www.linkedin.com/in/shameeluddin/
GitHub: https://github.com/Shameel123