Copying an SSH public key to another host in one line

This tip came from Linux Journal, Issue 137, September, 2005.

To copy a public key from one host to another, you could copy the key to the host, and then ssh to that host, and then cat the public key file into your ~/.ssh/authorized_keys file. But that's a lot of dinking around. Here's how to do it in one command:

cat ~/.ssh/ |ssh -l user host "cat >> .ssh/authorized_keys"

Ah, the beauty of pipes.