It’s a common task: “Please, add my public ssh key to that host”.
And I usually get the key, copied it to buffer, ssh to the remote host, cd .ssh and
finally I do a cat - >> authorized_keys
and paste the key.
But you can do it in just one single line:
1 | cat new_key.pub | ssh myRemoteHost "cat >> ~/.ssh/authorized_keys" |
That’s all!