You could use the find command, for example:
1) change group ownership for .ssh directory from root to "x"
A find command piped into sed or awk should do this.
2) change permission for .ssh to –rwx------ (chmod 700)
Code:
find /home -type f -name ".ssh" -exec chmod 0700 {} \;
3) change group ownership for authorized_keys file from root to "x"
Again sed/awk
4) change file permission for authorized_keys (chmod 640 authorized_keys)
Code:
find /home -type f -name "authorized_keys" -exec chmod 0640 {} \;
I'll have a think about 1 & 3 on how to achieve this.