Someone asked me to provide my public id_rsa key to make be able to connect to their server via ssh. I did so and it's working fine. I want to do that from my another laptop as well without having to bother them. If I just copy a public and a private keys from my first laptop to the second one, will it allow me to connect to the server? Note I already have a private and public rsa keys on my second laptop that are, of course, different from the ones from the first laptop.

What's the best way to do so - copy the keys?

  • 2
    Best practice is to have one keypair per device you're connecting from. So generate a new keypair on the 2nd laptop and send that public key to them to add to your account.
    – EEAA
    Oct 29, 2014 at 3:03
  • OpenSSH includes "ssh-copy-id". It copies the public key to remote machines and adds the key to the authorized_key there. Oct 29, 2014 at 8:01
  • @TimHaegele, why are you assuming my second laptop can be accessed from the Internet? It can't be.
    – Oskar K.
    Nov 2, 2014 at 11:02

2 Answers 2


You can manually add the public key for your second laptop to the server. Just edit the .ssh/authorized_keys file in your home directory and append your second public key.

To get this, on your second laptop, run

cat .ssh/id_rsa.pub

You can copy your key (both id_rsa and id_rsa.pub) to you server B with a new name like serverA_key and serverA_key.pub to connect from serverB with this key you can give ssh the path to your new key

ssh -i serverA_key target_server

or add this to your .ssh/config on serverB

Host target_server
  IdentityFile /path/to/serverA_key
  • what's a server B?
    – Oskar K.
    Nov 2, 2014 at 11:03
  • serverB means a second system/server
    – deagh
    Nov 2, 2014 at 13:36
  • Where did I mention I have 2 servers? I have 2 laptops.
    – Oskar K.
    Nov 3, 2014 at 0:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.