SSH: Testing whether ID is already in authorized_keys

Michael R Head burner at
Sun Sep 4 03:39:52 UTC 2005

On Sat, 2005-09-03 at 21:37 -0400, Stephen R Laniel wrote:
> On Sat, Sep 03, 2005 at 07:08:46PM -0400, Michael R Head wrote:
> > You could do something like this:
> > 
> > ssh-copy-id -i ~/.ssh/ user at
> > ssh user at hostname  "cat .ssh/authorized_keys |sort |uniq > .ssh/authorized_keys.uniq; mv .ssh/authorized_keys.uniq .ssh/authorized_keys"
> Yeah, I thought of that just after posting. It still seems
> like a bit of a hack, doesn't it? But maybe it's less of a
> hack than any of the other possibilities.

Well, I would say it's more unixish than hackish. and ssh-copy-id is
already a bit of a hack (it's just a shell script).

Michael R Head <burner at>
GPG: (ID 23A02B1F)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <>

More information about the ubuntu-users mailing list