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= your@email.com

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 username@server.address.com 'cat >> ~/.ssh/authorized_keys'

The server will then prompt you for your password:

username@server.address.com'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
Permanently close your payments profile
Why is the forex market so popular?
Average Jonas Wife
Skycurve Replacement Mat
PontiacMadeDDG family: mother, father and siblings
Kansas Craigslist Free Stuff
His Lost Lycan Luna Chapter 5
Crime Scene Photos West Memphis Three
Kagtwt
Seth Juszkiewicz Obituary
Sitcoms Online Message Board
Wunderground Huntington Beach
Little Rock Arkansas Craigslist
Signs Of a Troubled TIPM
Miss America Voy Forum
Oro probablemente a duna Playa e nomber Oranjestad un 200 aña pasa, pero Playa su historia ta bay hopi mas aña atras
Gma Deals And Steals Today 2022
Dexter Gomovies
Log in or sign up to view
Craigslist Mt Pleasant Sc
NBA 2k23 MyTEAM guide: Every Trophy Case Agenda for all 30 teams
91 East Freeway Accident Today 2022
Dover Nh Power Outage
Football - 2024/2025 Women’s Super League: Preview, schedule and how to watch
Doublelist Paducah Ky
Tips and Walkthrough: Candy Crush Level 9795
Home
Inbanithi Age
Amelia Chase Bank Murder
Craigslist Northern Minnesota
27 Fantastic Things to do in Lynchburg, Virginia - Happy To Be Virginia
Tim Steele Taylorsville Nc
Storelink Afs
Watchdocumentaries Gun Mayhem 2
Roto-Rooter Plumbing and Drain Service hiring General Manager in Cincinnati Metropolitan Area | LinkedIn
Craigs List Stockton
Wsbtv Fish And Game Report
KM to M (Kilometer to Meter) Converter, 1 km is 1000 m
Rage Of Harrogath Bugged
3496 W Little League Dr San Bernardino Ca 92407
Craigslist Mexicali Cars And Trucks - By Owner
B.C. lightkeepers' jobs in jeopardy as coast guard plans to automate 2 stations
Conan Exiles Armor Flexibility Kit
Pa Legion Baseball
Promo Code Blackout Bingo 2023
60 Days From May 31
Vagicaine Walgreens
Powah: Automating the Energizing Orb - EnigmaticaModpacks/Enigmatica6 GitHub Wiki
Metra Union Pacific West Schedule
How Did Natalie Earnheart Lose Weight
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.