0

I just got a new computer and I connect to 3 different remote machines using ssh. They all have logging in with password turned off so I have to have a key. What is the best way to copy my newly generated key to these machines without having to take down my walls?

Chris Wendel
  • 1
  • 2
  • 2

1 Answers1

2

Depending on your OS, you can try:

ssh-copy-id username@host

To specify the key file use:

ssh-copy-id -i ~/.ssh/id_rsa.pub username@host

You may have to copy your public key to a computer that already has SSH access to the three machines, otherwise these commands won't work without asking for a password.

I find this is much easier than using my old method:

cat ~/.ssh/id_rsa.pub | ssh username@host 'cat >> .ssh/authorized_keys'
Jamie S
  • 141
  • Awesome, I think this is what I was looking for. This was my initial thought but I wasn’t sure exactly how it would work. So copy my id_rsa.pub to my old computer and then copy that same file to the new computer? Are all public keys stored in one file? Or will I have to make sure I select the right one? – Chris Wendel Jan 16 '18 at 04:42