0

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?

Oskar K.
  • 167
  • 2
  • 7
  • 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 '14 at 03:03
  • OpenSSH includes "ssh-copy-id". It copies the public key to remote machines and adds the key to the authorized_key there. – Tim Haegele Oct 29 '14 at 08:01
  • @TimHaegele, why are you assuming my second laptop can be accessed from the Internet? It can't be. – Oskar K. Nov 02 '14 at 11:02

2 Answers2

0

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
Alastair Irvine
  • 1,182
  • 11
  • 24
0

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
deagh
  • 2,019
  • 5
  • 19
  • 19