Back to TIL
shell

Quick data transfer between home computers

How can you quickly transfer something from one computer on the network to another?

I asked myself that today while setting up SSH on a VM via VNC: how can I get my public key onto the other machine without copy-paste and without scp, because SSH is not yet installed? Constraints!

netcat to the rescue. In this example, I’ll stick to the SSH case: getting a public key onto the new machine.

On the target machine:

nc -l -p 2022 > .ssh/authorized_keys

On the source machine:

cat ~/.ssh/id_ecdsa.pub | nc targetMachineIP 2022

You can replace cat with anything: this also works with echo or pbpaste instead.

This works with binary files as well, even bigger ones.