Ssh Copy Id

28 Dec 2020

I really came late to the joys of ssh.

During lockdown I’ve been messing about with a raspberry pi I’ve had sitting around for ages. Normally my ssh routine is like this:

ls ~/.ssh

you should see something like

id_rsa
id_rsa.pub
known_hosts

then paste the contents of id_rsa.pub which is your public key, into the ~/.ssh/authorised_keys folder on the remote machine. From then you should be able to log in without giving your password just by typing

ssh [name]@[remote machine]

But there’s a much nicer way:

ssh-copy-id [remote user name]@[remote machine]

so for example I typed from my machine

ssh-copy-id pi@192.168.1.117

the raspberry pi asks for your password and you’re done.

Elegant stuff!

This should also work for rsyncing my webspace, but I set that up the old way.