sshpublic-keyauthorized-keys

How to append authorized_keys on the remote server with id_rsa.pub key


How to append authorized_keys on the remote server with id_rsa.pub key from the local machine with a single command?


Solution

  • Adding an authorized key could be one-lined this way (use double-quotes so it's interpreted before sent):

    ssh user@server "echo \"`cat ~/.ssh/id_rsa.pub`\" >> .ssh/authorized_keys"