Github setup for ssh key – Introduction
In the world of version control, Git that is, in the world of version control, Git has become an essential tool for developers. GitHub, being one of the most popular platforms for hosting Git repositories, offers various authentication methods. One of the most secure and convenient ways is to use SSH keys. In this blog post, we will guide you through the process of setting up SSH for GitHub, making your interactions with the repository seamless and secure.
One of the most secure ways to communicate over the public Internet is to use SSH. That’s why GitHub SSH key setup is a top priority for users of the popular Git service.
Fortunately, the GitHub and SSH key configuration process is relatively simple, especially on Linux distributions like Ubuntu.
Read Also – Setting up SSH key with GitHub for Ubuntu
GitHub SSH Key Setup Steps
To setup GitHub SSH keys and use them on Ubuntu, follow these steps:
- Create GitHub SSH key pair with ssh-keygen command
- Copy the value of a public SSH key to the clipboard
- Log in to GitHub and go to your account settings
- Click on the ssh and gpg link
- Click Add Key to register the public SSH key with your account
- Name the key and paste the copied value into the text field
- Save your changes
In your Git client, use an SSH based GitHub URL to clone your repo
Let’s take a look at each of these steps to setup GitHub SSH keys.
Create GitHub SSH keys
In Ubuntu, the SSH keys you create for GitHub should go in the .ssh folder. Perform the task of creating all GitHub SSH keys in this folder:
github@ubuntu:~$ cd ~/.ssh Command
$ssh-keygen
GitHub command to create SSH key pairs:
github@ubuntu:~/.ssh$ ssh-keygen -o -t rsa -C “email@example.com”
The operation will prompt you to choose a location to save the public and private keys. Simply click Return to leave them in the .ssh folder. The SSH command will appear here when a connection to a remote server is attempted.
GitHub Setup: Installation and how to manage it on UBUNTU 22.04 LTS. There are a few key steps involved in installing GitHub on a Linux system, and you can use the command-line interface (CLI) to interact with your GitHub repository. Below, I’ll outline the steps to set up GitHub and some important Git commands: 1. Create a GitHub account: Go to GitHub’s website and sign up for a free GitHub account. Do it. If you already have an account, log in.
![Github setup for ssh key](https://devopslover.com/wp-content/uploads/2023/12/Screenshot-from-2023-12-02-22-10-16.png)
once it opened you will see like this.. click on signup button and try create
your own github account
And click continue …. varify and
![](https://devopslover.com/wp-content/uploads/2023/12/Screenshot-from-2023-12-02-22-16-21.png)
And click continue …. varify and create account
![](https://devopslover.com/wp-content/uploads/2023/12/image-1024x581.png)
Click on Create Repository
![](https://devopslover.com/wp-content/uploads/2023/12/image-1-1024x581.png)
Just go through the public repository ..select public repository and click on create button..
You will see look like this
![](https://devopslover.com/wp-content/uploads/2023/12/image-2-1024x581.png)
Click on setting where u can find SSH key GPG keys
![](https://devopslover.com/wp-content/uploads/2023/12/image-3-1024x581.png)
Select and open New SSH key button
Git is the version control system that GitHub is built on. Most Linux
distributions come with Git pre-installed. To check if Git is installed, open a
terminal and run:
$ git –version
If Git is not installed, you can install it using your distribution’s package
manager. For example, on Debian/Ubuntu:
$ sudo apt-get update $ sudo apt-get install git
Configure Git
Set your name and email address for Git, which will be associated with your commits.
Replace Your name and your email with your actual git email and username
$ git config --global user.name "Your Name" $ git config --global user.email "your.email@example.com" Example : $ git config --global user.name "devopslover" $ git config --global user.email "devopslover@gmail.com"
Add Your Key SSH to GitHub:
After generating an SSH key, add the public key to your GitHub account. You can copy your public key to your clipboard and then add it to GitHub using the following steps
$ cd ~/.ssh $ ssh-keygen -o -t rsa -c “devopslover@gmail.com”
![](https://devopslover.com/wp-content/uploads/2023/12/image-4.png)
GitHub SSH key location
When the GitHub SSH key create operation completes, the Ubuntu terminal will display a very satisfying piece of randomart.
You will also find public and private GitHub SSH keys in the current directory.
You will need to paste the contents of your public SSH key into GitHub. Cat the file to view its contents in the Ubuntu Terminal and then copy it:
$ cat id_rsa.pub
![](https://devopslover.com/wp-content/uploads/2023/12/image-5.png)
GitHub SSH key config
Next, you must configure the GitHub SSH key in the settings of your online account. Log into GitHub, navigate to your account settings, and find the link named “SSH and GPG keys.” Click on this link to create a new GitHub SSH key. Provide a unique name, and paste the value of the private GitHub SSH key you copied earlier.
Copy this SSH Key And go again to your github account where u are creating a new SSH key..
![](https://devopslover.com/wp-content/uploads/2023/12/image-6-1024x576.png)
If you are following instructions step by step you will be able to create New SSH key successfully.
![](https://devopslover.com/wp-content/uploads/2023/12/image-7-1024x576.png)
Copy this SSH command And Copy this on your Terminal
$ sudo mkdir MyGitHub_Account $ cd MyGitHub_Account $ git clone git@github.com:DevopsLover01/Demo.git Git commands 1.Initialize a new repository: $git init
![](https://devopslover.com/wp-content/uploads/2023/12/image-8.png)
2.Clone a repository:
$git clone <repository_url>
(How to Clone Your Created Repository)
![](https://devopslover.com/wp-content/uploads/2023/12/image-9-1024x351.png)
just created some files using commands and will trying to push it on Github
![](https://devopslover.com/wp-content/uploads/2023/12/image-10-1024x351.png)
$ touch demofile1.txt $ touch demofile2.txt $ touch devopslover.java $ls
After making changes to your project, commit them to your local repository:
3.Add changes to the staging area:
$ git add <file(s)> 4.Commit changes: $ git commit -m "Your commit message"
![](https://devopslover.com/wp-content/uploads/2023/12/image-11-1024x200.png)
5.View the status of your changes:
$git status
![](https://devopslover.com/wp-content/uploads/2023/12/image-12.png)
6.View the commit history:
$git log
7.Create a new branch:
$git branch <branch_name>
8.Switch to a branch:
Create Branch Using this command
$ git checkout -b master $ git push origin masterSwitch Branches:
![](https://devopslover.com/wp-content/uploads/2023/12/image-13-1024x532.png)
9.Create and switch to a new branch:
$git checkout -b <branch_name> or $git switch -c <branch_name>
10.Merge branches:
$git merge <branch_name>
![](https://devopslover.com/wp-content/uploads/2023/12/image-14-1024x337.png)
11.Pull changes from a remote repository:
$git pull origin <branch_name>
![](https://devopslover.com/wp-content/uploads/2023/12/image-15.png)
12.Push changes to a remote repository:
$ git push origin master
Switch Branches:
![](https://devopslover.com/wp-content/uploads/2023/12/image-16-1024x532.png)
13.See remote repositories: $git remote -v 14.Add a remote repository: $git remote add <remote_name> <repository_url> 15.Remove a file from the working directory and staging area: $git rm <file> 16.Discard changes in the working directory: $git checkout -- <file> 17.Discard changes in the staging area: $git reset HEAD <file> 18.Undo the last commit (soft reset): $git reset --soft HEAD^ 19.Undo the last commit (hard reset): $git reset --hard HEAD^ 20.List all branches: $git branch 21.Fetch changes from a remote repository: $git fetch origin
![](https://devopslover.com/wp-content/uploads/2023/12/image-17-1024x234.png)
22.Create a tag: $git tag <tag_name> 23.Show changes between commits, branches, or tags: $git diff <commit/branch/tag>..<commit/branch/tag> $git diff
![](https://devopslover.com/wp-content/uploads/2023/12/image-18-1024x393.png)
24.Stash changes: $git stash 25.Apply stashed changes: $git stash apply
![](https://devopslover.com/wp-content/uploads/2023/12/image-19-1024x576.png)
Tag – Github setup for ssh key
Hope you like this blog….
![](https://devopslover.com/wp-content/uploads/2024/01/image-42.png)
- Sending slack notification via pipeline job - August 25, 2024
- SonarQube integration with Jenkins - August 24, 2024
- Deployment of 2 application java and python using k8s : slack alerting Using Jenkins pipeline liberary - August 10, 2024