SSH: Testing whether ID is already in authorized_keys

Stephen R Laniel steve at laniels.org
Sat Sep 3 20:31:14 UTC 2005


I'm writing a script to do rsync backups, and before I do
the backup I'd like to copy the local user's SSH public key
into his remote ~/.ssh/authorized_keys file -- unless the
key is *already* in that file. The normal trick to do this
is to use

ssh-copy-id -i ~/.ssh/id_dsa.pub user at host.com

However, I've just noticed that ssh-copy-id doesn't check
whether the key is already in there. Is there any easy,
elegant way (as easy and elegant as ssh-copy-id) to only
copy the key over if it's not already in the remote
authorized_keys file?

-- 
Stephen R. Laniel
steve at laniels.org
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <https://lists.ubuntu.com/archives/ubuntu-users/attachments/20050903/126a0269/attachment.sig>


More information about the ubuntu-users mailing list