Copy SSH Keys to A New Computer (2024)

Originally Posted on with tags: software utility

Last Update on

I followed Miguel Grinberg’s tutorial setting up an SSH key on my desktop using ssh-keygen. I thought I could simply copy the private key id_rsa and public key id_rsa.pub to ~/.ssh directory on a new computer and SSH would work as on the first computer.

It does not work. I googled and found a Q&A on askubuntu.com. There are many answers to the question but only the answer by Victor Timoftil is related to what I am looking for. The simple answer is that,

Move ~/.ssh to the new machine and run ssh-add. DONE!

The long answer is that,

  1. In the old machine, take the folder ~/.ssh to an USB drive, or to any other storage you like.
  2. On the new machine, put the folder under ~ aka /home/$USER.
  3. Run ssh-add, on the new machine done.

I copy the two SSH keys files vie a flash drive that is formatted as ntfs format. The key files are having new permission 777. The ssh-add command will show an error for that. I have to use chmod 500 command to change file permissions. Also the ssh-add will ask a passphrase which is entered when you create the keys. It seems to be a safety feature to prevent someone stealing the two key files.

Update (6/28/2020): I find the above method is not a good practice of handling SSH keys. It is better to generate new private and public keys in a new computer and copy the new public key to the server according to a Q&A post. The server will have two public keys for the same user.

Update 2 (7/21/2020): In order to add a second public key to the github, an additional step “add your SSH key to the ssh-agent” is needed when generating the key. Follow instructions on those two github web pages.

Update 3 (11/10/2020): You can run ssh-agent automatically when you open bash shell by adding lines of code (on the linked page below) into .bashrc file.

Copy SSH Keys to A New Computer (2024)

FAQs

Can I copy SSH keys from one computer to another? ›

Yes, if you change the machine from which you access your servers, you can just copy the ~/. ssh directory from the old machine to the new one. It is unnecessary (and cumbersome) to generate a new key pair for every server. You just need the private keys on your new machine.

How to reuse ssh key on new computer? ›

Here is the process using an External Drive or USB thumb drive:
  1. Copy your private key (typically ~/. ...
  2. Copy your public key (typically ~/. ...
  3. Carry the USB stick to your new workstation.
  4. Make the ~/. ...
  5. Change the permissions of the ~/. ...
  6. Copy your private key from the USB stick to your ~/.

How do I copy my SSH key? ›

Copy the ssh key into remote servers
  1. Open a terminal on your local computer.
  2. Generate an SSH key pair if you haven't already done so by running the command: ssh-keygen . ...
  3. Once the key pair is generated, run the command: ssh-copy-id user@remote_server . ...
  4. You'll be prompted to enter the password for the remote user account.
Apr 8, 2023

Can I use the same SSH key on a different computer? ›

To use your SSH key to log in to another remote machine, you must copy the public key file to the remote machine.

Are SSH keys tied to a computer? ›

On the user's side, it is stored in SSH key management software or in a file on their computer. The private key remains only on the system being used to access the remote server and is used to decrypt messages.

How to copy SSH key from Windows Terminal? ›

You can copy your public key using the OpenSSH scp secure file-transfer utility, or using a PowerShell to write the key to the file. The example below copies the public key to the server (where "username" is replaced by your username). You'll need to use the password for the user account for the server initially.

How do I export my SSH key? ›

To export your private SSH key:
  1. Select the OpenSSH keys keyring from the left side panel.
  2. Select the Personal SSH key, that has to be exported, from the list.
  3. Right click on the selected key and select Properties ▸ Details.
  4. Press the Export Private Key button to save the exported private key on your computer.

How do you copy and paste remote SSH? ›

To copy FROM the micro editor running on your remote machine over ssh: WORKS (you MUST use Shift + select, AND Ctrl + Shift + C): Hold down Shift + mouse select in the remote micro, then Ctrl + Shift + C; then on the local PC to paste: Ctrl + V or Ctrl + Shift + V or middle-mouse-click.

How to clone via SSH key? ›

To perform a GitHub clone with SSH keys in Git, simply follow these steps:
  1. Create an SSH keypair on your Windows or Linux OS.
  2. Copy the value of the public SSH key to your GitHub account.
  3. Obtain the GitHub SSH URL for the repository to be cloned.
  4. Using Git, clone from GitHub with the SSH URL.
Jan 11, 2022

Is it safe to use the same SSH key twice? ›

Yes, that's perfectly legitimate. ssh keys don't care where they were generated, and it's fine to have them on multiple machines at once.

How to use SSH between two computers? ›

How to Connect to a Remote Server via SSH from Windows, Linux or Mac
  1. Change the Default TCP Listening Port.
  2. Use SSH Key Pairs for Authentication.
  3. Disable Password-Based Logins on Your Server.
  4. Disable Root Access.
  5. Use TCP Wrappers.
  6. Secure Login Information and Employ Multilayer Security.
Nov 23, 2023

Is it possible to have two SSH keys? ›

If you wish to gain regular access to the Git Fusion host, you can specify the correct key in your ssh command. Alternatively, you can manage multiple SSH keys using the SSH 'config' file on your local machine. This file is located at '~/. ssh/config' when using Linux, Mac or 'Git Bash' on Windows.

Is it okay to reuse SSH keys? ›

Changing the host's public key is fine, as long as the host also gets a new certificate. You can safely reuse host names and even run multiple hosts with the same name. You'll never see a host key verification failure again.

How to import SSH keys? ›

Importing an SSH Key (WS_FTP Professional)
  1. From the main window, select Tools > Options. The Program Options dialog appears.
  2. Select SSH > Client Keys.
  3. Click Import. Follow the on-screen steps to complete the import.

Top Articles
money design and history
crypto - Google Search
Public Opinion Obituaries Chambersburg Pa
Stadium Seats Near Me
Don Wallence Auto Sales Vehicles
Roblox Developers’ Journal
How do you mix essential oils with carrier oils?
Doby's Funeral Home Obituaries
You can put a price tag on the value of a personal finance education: $100,000
Phillies Espn Schedule
2021 Lexus IS for sale - Richardson, TX - craigslist
Oc Craiglsit
Hca Florida Middleburg Emergency Reviews
Aldi Sign In Careers
Dr Adj Redist Cadv Prin Amex Charge
Vandymania Com Forums
Jang Urdu Today
Google Doodle Baseball 76
Ratchet & Clank Future: Tools of Destruction
Leccion 4 Lesson Test
라이키 유출
Scout Shop Massapequa
Catherine Christiane Cruz
Reptile Expo Fayetteville Nc
Raz-Plus Literacy Essentials for PreK-6
Bjerrum difference plots - Big Chemical Encyclopedia
[PDF] NAVY RESERVE PERSONNEL MANUAL - Free Download PDF
Craigslist Battle Ground Washington
Sand Dollar Restaurant Anna Maria Island
Webworx Call Management
Revelry Room Seattle
Abga Gestation Calculator
Ofw Pinoy Channel Su
Dreamcargiveaways
Metra Union Pacific West Schedule
Mgm Virtual Roster Login
SF bay area cars & trucks "chevrolet 50" - craigslist
The Thing About ‘Dateline’
Mars Petcare 2037 American Italian Way Columbia Sc
Indiana Jones 5 Showtimes Near Cinemark Stroud Mall And Xd
Metro Pcs Forest City Iowa
Obituaries in Hagerstown, MD | The Herald-Mail
Cnp Tx Venmo
Who Is Responsible for Writing Obituaries After Death? | Pottstown Funeral Home & Crematory
No Boundaries Pants For Men
Nina Flowers
Breaking down the Stafford trade
Mcoc Black Panther
Ronnie Mcnu*t Uncensored
Myapps Tesla Ultipro Sign In
Gummy Bear Hoco Proposal
Latest Posts
Article information

Author: Pres. Lawanda Wiegand

Last Updated:

Views: 6294

Rating: 4 / 5 (51 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Pres. Lawanda Wiegand

Birthday: 1993-01-10

Address: Suite 391 6963 Ullrich Shore, Bellefort, WI 01350-7893

Phone: +6806610432415

Job: Dynamic Manufacturing Assistant

Hobby: amateur radio, Taekwondo, Wood carving, Parkour, Skateboarding, Running, Rafting

Introduction: My name is Pres. Lawanda Wiegand, I am a inquisitive, helpful, glamorous, cheerful, open, clever, innocent person who loves writing and wants to share my knowledge and understanding with you.