Tuesday, February 2, 2010

How to copy ssh public key to remote machine

Actually following command not only perform copying ssh public key to remote machine but also remove authorized_keys and known-hosts old files simultaneously.

cat ~/.ssh/id_dsa.pub |ssh root@remote_machine 'sh -c "cat - >>~/.ssh/authorized_keys2;rm ~/.ssh/authorized_keys;rm ~/.ssh/known_hosts"'

No comments:

Post a Comment