20070917

oneliner

Task: Remove user1, user2 and user3 ssh keys from multiple machines for both home users and root account,
for ssh protocol 1 as well as protocol 2 files.

To accomplish this task I've used sed and DSH (Dancer's Shell / Distributed Shell) on Debian GNU/Linux.

I've defined the redpool host group:

# cat /etc/dsh/group/redpool
root@red1
root@red2
[...]
root@red99
root@red100


and I've done:

dsh -g redpool "sed -i '/^.*user1\|user2\|user3.*$/d' /{root,home/*}/.ssh/authorized_keys*"


But... you could sue me: "You're guilty of using multiple commands to perform your job."
So, let's ride:

for i in {1..100}; do ssh root@red$i "sed -i '/^.*user1\|user2\|user3.*$/d' /{root,home/*}/.ssh/authorized_keys*"; done


Above option is only usable with hostnames / addresses counted sequentially.
In case of various name schemes it's easier to use the dsh command.