DEV Community

Cover image for How to move your .ssh generated keys to a new laptop.
Wachira
Wachira

Posted on • Originally published at thedevnote.xyz

22 2

How to move your .ssh generated keys to a new laptop.

So I recently changed laptops, from being a Linux user for the past 2.5 years. I was running Parrot during that time, great os by the way if you are into cyber security stuff or just another full-stack developer like me.

I switch over to Mac, and all my ssh keys were in my previous laptop, they access all of my servers in Digital Ocean and AWS, to cloning and pushing to Github and so much more. I could not convince myself to update all servers with the new ssh keys and I had some issues with Github SSH cloning. So here are the steps I took, enabling me to move all my keys to my new laptop.

  • Copy over the ssh keys from your old laptop to the new one, they should be located in the ~/.ssh/ folder. You can use a flash drive or a cloud platform, whatever works for you.
  • Paste the files in your new laptop in the same directory.
  • Add the to your keychain
# for macos
ssh-add --apple-use-keychain ~/.ssh/id_rsa

# for linux
ssh-add -K ~/.ssh/id_rsa
Enter fullscreen mode Exit fullscreen mode
  • The Catch: If you do that you will get an error like this:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0664 for 'id_rsa' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Enter fullscreen mode Exit fullscreen mode
  • To avoid this, run this command;
# this basically makes the keys read-writable by you
chmod 600 id_rsa
Enter fullscreen mode Exit fullscreen mode
  • Retry adding it to the keychain
# for macos
ssh-add --apple-use-keychain ~/.ssh/id_rsa

# for linux
ssh-add -K ~/.ssh/id_rsa
Enter fullscreen mode Exit fullscreen mode
  • The output should be:
Identity added: id_rsa (<ssh_name_will_appear_here)
Enter fullscreen mode Exit fullscreen mode

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (1)

Collapse
 
angelo_tessaro_c3c6362dab profile image
Angelo Tessaro

I got this error still, after running the commands: Bad owner or permissions on /Users/angelotessaro/.ssh/config

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more