SSH Key Setup for GitHub

29/12/2020
Git
To understand Github you first need to make sure you are aware of a Git . Git is a open source version control system that was started by Linus Trovalds. In short Git is a version control system like Subversion and CVS. You will be able to use this by installing “git” command and utilities in your server. Git is a command-line tool, and GitHub is the place where developers store their projects and works and will be able to share with the rest of the world and can give them version upgrades as well. You have options to create private and public repositories and can use them as per your needs.

To start with you need to make sure you have a linux terminal with git command installed and have ability of using git command by the user at which you are trying. Always try to use a separate user and do not use root user for the same. Also you need to create a account with Github.

Create an Account with Github

To create a account with Github, you can follow the below steps

  • Go to “Join GitHub”
  • Fill in your information and click “Create an account”
  • Select the plan you want and click “Finish sign up”
  • When you sign up, you’ll receive an email to verify your email address.  Click the link to complete verification.

Once account is created next step is to create a fresh key pair and then add them to Github.

Adding Your SSH Key to Your GitHub Account

Login to your terminal via SSH.

Generate a key pair by running the following command, substituting in your GitHub email address between the quotes:

# ssh-keygen -t rsa -b 4096 -C “your_email@domain.com”

When you’re prompted to “Enter a file in which to save the key,” press Enter to save it in the default location. If you wish to use a different location, you can provide the path to be used here as well.

At the prompt, type a secure passphrase that will be used when your key is authenticating, and confirm it. You can even do not setup this passphrase if you don’t need extra verification. So now you have generated the SSH key pair. Make sure you make a note on things like public key and private key files.

To add ssh key in the GitHub you need to take a copy of the public key and you can use the below ssh command to get this done.

# cat /home/user/.ssh/id_rsa.pub

Once you have copied the content in your clipboard or in any local text file, we can use the below steps to add the key to Github account.

  • You need to login to Github Account using your user/pass
  • Click on the Profile pic and select “Settings” from the Drop down.
  • Select “SSH and GPG Keys” from the Menu in the left hand side

To add your first key or another key click on “New SSH key”

In the “Title” field, you need to add a label which you can remember.  (I used  “Sumesh’s MacBook Air”).

You can use any word and only thing you need to take care is you need to make sure that will help you to identify the machine on which that key is generated.

In “key” Field add the above key which you get by using the command “cat /home/user/.ssh/id_rsa.pub” which will start with ssh-rsa

  • Click Add SSH key.

If prompted, confirm your GitHub password which will be used for verification.

Now you can see the key listed which you have added in the title name. And you will need to do the same procedure for each computer , live servers dev/staging servers which needs to access your repositories.

Check your Connection from local machine to Github

Open a new ssh terminal and make sure you switch to the user for which you had created the ssh key pair. To connect with Github account via ssh key, you need to type the below and press enter

# ssh -T git@github.com

If you connecting this for the first time from that machine, you will see a result like the below and you need to type Yes in this case:

The authenticity of host ‘github.com (192.30.1.1)’ can’t be established.
RSA key fingerprint is SHA256:asdnasd871321312kjaksjdasdijsaidjsad1Rk3ndm.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘github.com,192.30.30.1’ (RSA) to the list of known hosts.
  • Type “yes”
  • Press Enter

You will see output like this:

“Hi user ! You’ve successfully authenticated, but GitHub does not provide shell access.”

If the above mentioned user is correct and is displayed as the same one which you tried adding, then all is fine and you have completed the ssh key setup with Github ! If you are getting permission denied, then we need to cross check the above steps and make sure you have done everything as per the above doc.  You can always contact me if you need any help in this case.

ONET IDC thành lập vào năm 2012, là công ty chuyên nghiệp tại Việt Nam trong lĩnh vực cung cấp dịch vụ Hosting, VPS, máy chủ vật lý, dịch vụ Firewall Anti DDoS, SSL… Với 10 năm xây dựng và phát triển, ứng dụng nhiều công nghệ hiện đại, ONET IDC đã giúp hàng ngàn khách hàng tin tưởng lựa chọn, mang lại sự ổn định tuyệt đối cho website của khách hàng để thúc đẩy việc kinh doanh đạt được hiệu quả và thành công.
Bài viết liên quan

Git Add All Modified Files

When you are dealing with Git add, you have multiple options to add all modified files. Let’s look at a few scenarios...
28/12/2020

SSH Key Setup for GitHub

To understand Github you first need to make sure you are aware of a Git . Git is a open source version control system that...
29/12/2020

Interfacing with GitHub API using Python 3

GitHub as a web application is a huge and complex entity. Think about all the repositories, users, branches, commits, comments,...
29/12/2020
Bài Viết

Bài Viết Mới Cập Nhật

mua Proxy riêng ở đâu, và nó đem lại lợi ích gì cho người sử dụng
22/11/2022

Hướng dẫn sử dụng Proxy Helper Fakeip khi thuê proxy
21/11/2022

PROXY NUÔI TÀI KHOẢN FACEBOOK – KINH NGHIỆM FAKE IP – THUÊ PROXY GIÁ RẺ
14/11/2022

Mua Proxy Nuôi Zalo Giá Rẻ Tại Onet.com.vn
14/11/2022

BẢNG GIÁ MUA PROXY VIỆT NAM và PROXY US Onet.com.vn
14/11/2022