|  About Me  |  Blogs  |  Photos  |  Publications  |  Resume  | 

One-liner to add public key to authorized keys

$ cat ~/.ssh/id_dsa.pub | ssh user@host "cat  >> ~/.ssh/authorized_keys"

One Response to “One-liner to add public key to authorized keys”

  1. Justin Akehurst Says:

    A better one liner:
    $ cat ~/.ssh/id_dsa.pub | ssh user@host “cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys”

    This will make sure that if the authorized_keys file did not exist, it will have the right permissions to allow login using it.

Leave a Reply

You must be logged in to post a comment.