How to Set Up GitHub SSH Key: Easy Guide for Linux and Windows Users

date
Apr 14, 2024
slug
github-ssh-key-config
status
Published
tags
github
sshkey
git
linux
windows
macos
developer
versioncontrol
summary
Learn how to securely link your GitHub account with SSH keys on Linux and Windows. This easy-to-follow guide simplifies GitHub tasks
type
Post
Contribution by @Dharma .

Introduction

Whether you're using macOS, Windows, or one of the many Linux distributions out there, Git's got your back. It's like the Swiss Army knife of version control systems, making life easier for developers no matter what platform they're on. With Git, collaboration flows smoothly, regardless of your operating system preferences.
 
It's crucial to set up SSH keys for GitHub. SSH keys serve as the authentication mechanism for secure connections, ensuring the confidentiality and integrity of your data. To get started, open your terminal or Git Bash and generate a new SSH key by executing the appropriate command. This process establishes a secure channel between your machine and GitHub, enabling you to securely authenticate and interact with repositories.
To configure your GitHub account to recognize your SSH key, you'll need to add it to your account settings. This step ensures that GitHub can authenticate your connections using the generated key. By adopting GitHub SSH setup, you're embracing a more secure and efficient method compared to older authentication methods.
By following this guide, you'll gain the knowledge and confidence to create and utilize SSH keys effectively for your GitHub workflow. As of 2024, this setup remains integral to maximizing the collaborative potential of Git and GitHub in the developer community.

How to install Git?

Begin by ensuring Git is installed on your Linux system. Open your terminal and execute the command:
sudo apt-get install git
Debian Linux command
other operating system

Download Git for Windows

  1. Browse to the official Git website: https://git-scm.com/downloads
  1. Click the download link for Windows and allow the download to complete
notion imagenotion image

Extract and Launch Git Installer

3. Browse to the download location (or use the download shortcut in your browser). Double-click the file to extract and launch the installer.
notion imagenotion image
4. Allow the app to make changes to your device by clicking Yes on the User Account Control dialog that opens.
notion imagenotion image
5. Review the GNU General Public License, and when you’re ready to install, click Next.
notion imagenotion image
6. The installer will ask you for an installation location. Leave the default, unless you have reason to change it, and click Next.
notion imagenotion image
7. A component selection screen will appear. Leave the defaults unless you have a specific need to change them and click Next
notion imagenotion image
8. The installer will offer to create a start menu folder. Simply click Next.
notion imagenotion image
9. Select a text editor you’d like to use with Git. Use the drop-down menu to select Notepad++ (or whichever text editor you prefer) and click Next.
notion imagenotion image
10. The next step allows you to choose a different name for your initial branch. The default is 'master.' Unless you're working in a team that requires a different name, leave the default option and click Next.
notion imagenotion image
11. This installation step allows you to change the PATH environment. The PATH is the default set of directories included when you run a command from the command line. Leave this on the middle (recommended) selection and click Next.
notion imagenotion image

Server Certificates, Line Endings and Terminal Emulators

12. The installer now asks which SSH client you want Git to use. Git already comes with its own SSH client, so if you don't need a specific one, leave the default option and click Next.
notion imagenotion image
13. The next option relates to server certificates. Most users should use the default. If you’re working in an Active Directory environment, you may need to switch to Windows Store certificates. Click Next.
notion imagenotion image
14. The next selection converts line endings. It is recommended that you leave the default selection. This relates to the way data is formatted and changing this option may cause problems. Click Next.
notion imagenotion image
15. Choose the terminal emulator you want to use. The default MinTTY is recommended, for its features. Click Next.
notion imagenotion image
16. The installer now asks what the git pull command should do. The default option is recommended unless you specifically need to change its behavior. Click Next to continue with the installation.
notion imagenotion image
17. Next you should choose which credential helper to use. Git uses credential helpers to fetch or save credentials. Leave the default option as it is the most stable one, and click Next.
notion imagenotion image

Additional Customization Options

18. The default options are recommended, however this step allows you to decide which extra option you would like to enable. If you use symbolic links, which are like shortcuts for the command line, tick the box. Click Next.
notion imagenotion image
19. Depending on the version of Git you’re installing, it may offer to install experimental features. At the time this article was written, the options to include support for pseudo controls and a built-in file system monitor were offered. Unless you are feeling adventurous, leave them unchecked and click Install.
notion imagenotion image

Complete Git Installation Process

20. Once the installation is complete, tick the boxes to view the Release Notes or Launch Git Bash, then click Finish.
notion imagenotion image
For SSH key setup on any operating system (Windows, macOS, or Linux), follow the tutorial provided below.
 
 
Verifying Installation: To confirm Git installation, type the following command in your terminal:
git --version
Debian Linux command
notion imagenotion image

How to generate SSH Key?

These simple SSH key setup steps will help you Generate the SSH key First, navigate to the SSH directory by executing the following command:
cd ~/.ssh
Debian Linux command
Generate a new SSH key using the command below. Replace "your_email@example.com" with your actual email address:
ssh-keygen -o -t rsa -C "your_email@example.com"
Debian Linux command
After executing the above commands will show you this
once the commands are executed the same will appear on your terminal as shown above.once the commands are executed the same will appear on your terminal as shown above.
once the commands are executed the same will appear on your terminal as shown above.
To display the generated SSH key, enter the following command in the terminal:
cat id_rsa.pub
This code will generate the SSH key
Copy the code displayed in your terminal as like above sample shown.Copy the code displayed in your terminal as like above sample shown.
Copy the code displayed in your terminal as like above sample shown.

How to Add SSH Key to GitHub?

After copying SSH Key from your terminal, head to your GitHub profile and follow these steps:
  • Navigate to Settings.
  • Select "SSH and GPG keys" and click on "Add SSH key."
  • Provide a title, such as "Your Name Key."
  • Paste the copied SSH key into the provided field.
  • Click on "Add SSH key" to save your changes.
 
You're Done! Congratulations! You've successfully set up your SSH key for GitHub on Linux in 2024. Now, you can clone repositories and interact with GitHub securely.

Additional Tips

  • Downloading a Repository from Git: To download a repository from Git, use the git clone command followed by the repository URL. For example:
git clone <repository_url>
Replace <repository_url> with the URL of the Git repository you want to clone.
  • Easy Setup of Git on Your Laptop: Setting up Git on your laptop is simple with package managers like apt-get. Just follow the installation steps mentioned earlier.
  • Ensuring Security: Remember to keep your SSH key secure and never share it publicly. Regularly update your SSH keys and review your GitHub security settings for added protection
 
Embark on your Linux journey with Manjaro! Follow this simple guide to install Manjaro Linux, a versatile and user-friendly operating system. Learn how to install Manjaro on your desktop or laptop effortlessly. From creating a bootable USB drive to navigating the installation process, this tutorial ensures a smooth transition. Join the vibrant Manjaro community and experience the power of Arch-based Linux. Dive into open-source software and unleash your creativity with our easy-to-follow installation guide. SEO Keywords: Manjaro Linux installation, beginner's guide to Manjaro installation, Manjaro setup, step-by-step Manjaro installation, installing Manjaro on desktop, installing Manjaro on laptop.
 
If you have any questions, please contact me.