Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.



Get Started Now!

Hot to Generate and Add an ssh Key for Secure Authentication

Generating and adding an SSH key for secure authentication involves a few straightforward steps. Here’s a guide to creating an SSH key, adding it to your local SSH agent, and configuring it for authentication with remote servers or services like GitHub, GitLab, etc.

Generate the SSH Key

When prompted to “Enter a file in which to save the key,” provide a custom path within the htdocs folder.

step1: Open Git Bash and run the following:

This command creates a new SSH key, using the provided email as a label.

This saves the private key as project_name_ssh_key and the public key as project_name_ssh_key.pub in the htdocs folder. When prompted to “Enter a passphrase,” type a secure passphrase or press Enter to skip.

Step 2: Add the SSH Key to GitHub or a Server

  • Log in to GitHub and navigate to Settings > SSH and GPG keys.
  • New SSH key, add a Title, paste the public key, and click Add SSH key.

For a Remote Server:

Copy the public key to the remote server’s ~/.ssh/authorized_keys file.

ssh username@server_ip

Append the key:

cat ./project_name_ssh_key.pub | ssh username@server_ip "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Test the SSH Key

Test the connection to GitHub:

ssh -T git@github.com

Test the connection to a remote server:

ssh -i ./project_name_ssh_key username@server_ip

Test the SSH Key

Test the connection to GitHub:

ssh -T git@github.com

Test the connection to a remote server:

ssh -i ./project_name_ssh_key username@server_ip

Configure Git to Use the SSH Key (Optional)

If you’re using Git in the htdocs folder and want it to use the generated SSH key:

Add the key to the SSH agent:

eval "$(ssh-agent -s)"
ssh-add ./project_name_ssh_key

Configure Git to use this SSH key:

git config core.ssh Command “ssh -i ./project_name_ssh_key

Related Posts

Explore Rewa with Ease: Book Bikes and Cars Online with Motoshare

Rewa, the cultural heart of Madhya Pradesh, is a city that offers an enticing blend of history, natural beauty, and cultural richness. Whether you’re visiting to explore…

Explore Shimoga with Ease: Book Bikes and Cars Seamlessly on Motoshare

Shimoga, often called the “Gateway to Malnad,” is a stunning blend of natural beauty, cultural richness, and serene landscapes. Whether you’re planning to explore its mesmerizing waterfalls,…

Discover Mathura with Ease: Rent Bikes & Cars Seamlessly with Motoshare

Mathura, the birthplace of Lord Krishna, is a city rich in heritage and spiritual significance. Whether you’re a devotee, history enthusiast, or curious traveler, Mathura has something…

Discover Nizamabad with Ease: Rent Bikes and Cars through Motoshare

Explore the charm of Nizamabad effortlessly with Motoshare’s newly launched bike and car rental services. Whether you’re planning a quick trip across the city or a day…

Discover Tumakuru with Ease: Book Bikes and Cars Seamlessly on Motoshare

Tumakuru, a vibrant city in Karnataka, is a treasure trove of natural beauty, cultural heritage, and thrilling experiences. With Motoshare’s newly launched bike and car rental services,…

Explore Akola Hassle-Free: Motoshare’s Bike & Car Rental Services Now Available

Welcome to Akola, the vibrant city that seamlessly blends tradition and modernity! Whether you’re here for a short visit or an extended stay, getting around the city…

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x