Data Blog about Data, Camilo's Blog

Setup Github with ssh (no http) in Mac or Linux

Data Blog about Data, Camilo's Blog

What is difference between Git and Github?

Git is a version control software of that was design by Linus Torvals. From the outset, it was intended to function as a low-level software, with others taking care of design the graph user interface.

However, today Git is a version control software that is 100% meant for users on the terminal or shell. It's true that many GUIs exist for Git, but in this post we focus in shell in Linux and Mac.

In summary, Git is a Tool and GitHub is a web service that uses Git. Other services similar to Github include Bitbucket, Gitlab.

Install Git in Linux

Install a Git in Linux is very easy. Open you terminal, the installations process might vary depending on you version of Linux.

1. Check version with following command:

git --version

If you get an answer like git version x.x.x. You alredy have Git installed. But if get something like "git command not found" follow this command to install git.

2. Install Git (Linix):

sudo apt-get install git

Install Git (Mac) with brew:

brew install git

Git Configurations

This instructions are the same for Linux and Mac. We need to set up GIT with your username and email. It's crucial that the email is the same as the one you used to set up your Github account to avoid conflicts.

3. Set up your user:

git config --global user.name "you_user"

4. Set up your email:

git config --global user.mail "email@email.com"

Now, you are ready to use GIT from your local compute, but the true power of GIT comes from the collaborative work in a distributed form. The perfect platform for using Git is Github. Now we need connect our local Git with Github.

In this tutorial we will use SSH connection. This has several advantages like:

Connect with Github (SSH)

You need to create a public key and private key. First, check if the SSHt folder exists on your computer:

ls -a | grep .ssh

If .ssh is the answer, you already have the folder, If terminal dont show result, create the folder with the follow command:

mkdir .ssh

With own SSH folder ready, the next step is to create keys using the following command:

6. Create Keys:

ssh-keygen -t rsa -b 4096 -C "email@emai.com"

When this message is displayed "Generating public/private rsa key pair." Press Enter multiple times until finished.

With these steps, we finish generating the keys on your computer.

Now we have two files in SSH folder: the id_rsa.pub is a public key and id_rsa is a private key. Don't shere the private key with anyone.

7. Add private key to be user for system:

ssh-add ~/.ssh/id\_rsa

8. Upload public key to Github:

cat ~/.ssh/id\_rsa.pub

Data Blog about Data, Camilo's Blog

9. Open Github Web to load keys:

https://github.com/settings/keys

Click in "New SHH Key"

Data Blog about Data, Camilo's Blog

Paste the key that copied before and click in "Add SSH Key"

Data Blog about Data, Camilo's Blog

Congratulations, if everything worked fine, you should see something similar to this imagen:

Data Blog about Data, Camilo's Blog

Test Connection:

Try to connect some repo using a command like this:

mkdir my_git_test

cd my_git_test

git init

git remote add origin

git remote add origin git@github.com:almapase/xxx_project.git

Congratulations. You have correctly connected to Github through SSH.

Autor: Camilo Baquero - data@camilob.com - Data Engineer

#gihub #setup_gihub #setup_git #setup_linux_git #setup_mac_git #setup_git_with_shh