Wednesday, July 18, 2012

Avoid duplicates in authorized_keys after ssh-copy-id

This is a question that comes up every so often and here is a proposal through which you can override any existing authorized ssh public key. I have used this POB recipe with Remoto-IT while configuring Hadoop Clusters:

The below command will then deploy the public key from one server (For example using Remoto-IT in the hadoop master server) in the remote server (in this case a hadoop slave server) and will use the private key to password-less login and delete all lines referring to the current host for the given user: