Append the public key to remote server

Btw, id_rsa should be with permission 400. Found the following code to quickly append the public key to remote server. cat ~/.ssh/id_rsa.pub | ssh <user>@<hostname> 'cat >> .ssh/authorized_keys && echo "Key copied"'