How to generate a public key ssh and add it to your trusted key on linux (2024)

SSH keys are a way to identify trusted computers, without involving passwords. The steps below will walk you through generating an SSH key and adding the public key to the server.

First, check for existing SSH keys on your computer. Open Git Bash, Cygwin, or Terminal, etc. and enter:

$ ls -al ~/.ssh
# Lists all the files in your .ssh directory, if they exist
Generating public/private rsa key pair

Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:

  • id_dsa.pub
  • is_ecdsa.pub
  • id_ed25519.pub
  • id_rsa.pub

If you see an existing public and private key pair listed (for example id_rsa.pub and id_rsa) that you’d like to use, you can skip Step 2 and go straight to Step 3.

With your command line tool still open, enter the text shown below. Make sure you substitute in your email address:

$ ssh-keygen -t rsa -b 4096 -C "Your Comment here"
# Creates a new ssh key, using the provided domain username and computer name as a label
Generating public/private rsa key pair.

You’ll be asked to enter a passphrase, or simply press Enter to not enter a passphrase:

Enter passphrase (empty for no passphrase):
Enter same passphrase again:

After you enter a passphrase (or just press Enter twice), review the fingerprint, or ‘id’ of your SSH key:

Your identification has been saved in /Users/username/.ssh/id_rsa.
Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
The key fingerprint is:
nss2VhNB0Y62VIToM+/qYe3HS4TPXmrhuBxjUz4l/I8= [email protected]

To configure the ssh-agent program to use your SSH key, first ensure ssh-agent is enabled.

# start the ssh-agent in the background
$ eval $(ssh-agent -s)
Agent pid 59566

If you are using Git Bash, turn on the ssh-agent with command shown below instead:

# start the ssh-agent in the background
$ eval `ssh-agent`
Agent pid 59566

Then, add your SSH key to the ssh-agent:

$ ssh-add ~/.ssh/id_rsa

To add your public SSH key to the server, you’ll copy the public SSH key you just created to the server. Substitute “username” with your username on the server, and “server.address.com” with the domain address or IP address of your server:

$ cat ~/.ssh/id_rsa.pub | ssh [email protected] 'cat >> ~/.ssh/authorized_keys'

The server will then prompt you for your password:

[email protected]'s password:

That’s it! You should now be set up to connect to the server without having to authenticate.

How to generate a public key ssh and add it to your trusted key on linux (2024)
Top Articles
Cryptomining Capacity in U.S. Rivals Energy Use of Houston, Findings Show (Published 2022)
The 5 Most Powerful Single Candlestick Patterns
Compare Foods Wilson Nc
Windcrest Little League Baseball
Maria Dolores Franziska Kolowrat Krakowská
Pga Scores Cbs
The Realcaca Girl Leaked
Encore Atlanta Cheer Competition
270 West Michigan residents receive expert driver’s license restoration advice at last major Road to Restoration Clinic of the year
Mikayla Campino Video Twitter: Unveiling the Viral Sensation and Its Impact on Social Media
Hardly Antonyms
Baseball-Reference Com
Tamilblasters 2023
Large storage units
Call Follower Osrs
Connexus Outage Map
Guidewheel lands $9M Series A-1 for SaaS that boosts manufacturing and trims carbon emissions | TechCrunch
Everything We Know About Gladiator 2
Water Days For Modesto Ca
Dark Chocolate Cherry Vegan Cinnamon Rolls
Optum Urgent Care - Nutley Photos
Naval Academy Baseball Roster
Essence Healthcare Otc 2023 Catalog
Keyn Car Shows
O'reilly's In Mathis Texas
Encore Atlanta Cheer Competition
NV Energy issues outage watch for South Carson City, Genoa and Glenbrook
Lesson 1.1 Practice B Geometry Answers
Nurofen 400mg Tabletten (24 stuks) | De Online Drogist
Imagetrend Elite Delaware
Duke Energy Anderson Operations Center
The Pretty Kitty Tanglewood
Daily Journal Obituary Kankakee
Jr Miss Naturist Pageant
Space Marine 2 Error Code 4: Connection Lost [Solved]
Are you ready for some football? Zag Alum Justin Lange Forges Career in NFL
Msnl Seeds
Rage Of Harrogath Bugged
Ktbs Payroll Login
Author's Purpose And Viewpoint In The Dark Game Part 3
Best GoMovies Alternatives
Free Crossword Puzzles | BestCrosswords.com
Wilson Tire And Auto Service Gambrills Photos
Martha's Vineyard – Travel guide at Wikivoyage
Fatal Accident In Nashville Tn Today
Ssc South Carolina
Enr 2100
Www.homedepot .Com
antelope valley for sale "lancaster ca" - craigslist
Blog Pch
Salem witch trials - Hysteria, Accusations, Executions
Latest Posts
Article information

Author: Clemencia Bogisich Ret

Last Updated:

Views: 5701

Rating: 5 / 5 (60 voted)

Reviews: 83% of readers found this page helpful

Author information

Name: Clemencia Bogisich Ret

Birthday: 2001-07-17

Address: Suite 794 53887 Geri Spring, West Cristentown, KY 54855

Phone: +5934435460663

Job: Central Hospitality Director

Hobby: Yoga, Electronics, Rafting, Lockpicking, Inline skating, Puzzles, scrapbook

Introduction: My name is Clemencia Bogisich Ret, I am a super, outstanding, graceful, friendly, vast, comfortable, agreeable person who loves writing and wants to share my knowledge and understanding with you.