David Hancock

Jul 3

Better one-liner for ssh keys

Useful update to previous one-liner for adding ssh keys (letter to Linux Journal August 2009). Instead of using ssh and cat, simply use ssh-copy-id. For example:

ssh-copy-id -i id_rsa user@somehost

Will not only append your id_rsa.pub key to authorized_keys on somehost, it will ensure that the permissions on .ssh and authorized_keys are correct.