Re-laying Pipe Through SSH
You can easily and securely copy your ssh public key to a remote host using shell commands. This is far simpler than using files or even your system clipboard for that task. Here’s the one-liner:
cat ~/.ssh/id_rsa.pub | ssh myself@other-pc.local 'cat - >> ~/.ssh/authorized_keys'
The first part is straight forward: We pipe the contents of the user’s public key file to the ssh command.
cat ~/.ssh/id_rsa.pub # writes the contents to standard out.
Then, remember that you can pass a shell command to ssh which will be executed on the remote computer before the connection is closed again.
The nifty part, the glue of this operation, is to learn that the ssh command pipes its own input to the command it executes. And, in turn, cat - forwards that input directly to the output and thus can be used to append the stream to a file of your chosing.
When you run this command, you’ll be prompted for your password, possibly for the last time, so please enter it with the utmost gravitas. After that, ssh should let you connect without questioning, as long as you have access to the private key.
Please only do this on systems that you trust, and only as long as you trust the connection is secure. You did compare the fingerprints of the server to the one you had on record, right?
A couple more nifty tricks are described on this Linux.icydog.net blog post from 2008.