If you ( better not you, but **** happens) remove your /etc on redhat/centos 5 and you still have an open remote root shell, here is what you have to do to make sure you still can reach the host (I wouldn’t write it if I had a backup):
0. Say f***********ck, take a deep breath and don’t panic
1. Make a prayer ( whatever god will do, even Einstein, nobody hears you screaming anyway )
2. Restore /etc/resolv.conf, opendns will work if you don’t remember what are the servers
3. copy/paste/wget this from another redhat host:
drwxr-xr-x 5 root root 4096 Jan 25 00:37 security
drwxr-xr-x 3 root root 4096 Jan 30 13:47 selinux
-rw-r–r– 1 root root 643 Mar 18 20:44 group
-rw-r–r– 1 root root 1653 Mar 18 20:45 passwd
drwxr-xr-x 2 root root 4096 Mar 18 20:48 ssh
drwxr-xr-x 2 root root 4096 Mar 18 20:54 pam.d
-rw-r–r– 1 root root 1848 Mar 18 20:55 nsswitch.conf
-rw-r–r– 1 root root 8515 Mar 18 20:55 protocols
-rw-r–r– 1 root root 188 Mar 18 20:56 hosts.allow
-rw-r–r– 1 root root 375 Mar 18 20:56 hosts.deny
-rw-r–r– 1 root root 212 Mar 18 20:56 hosts
-rw-r–r– 1 root root 17 Mar 18 20:57 host.conf
-r——– 1 root root 1358 Mar 18 21:01 shadow
Some of these maybe not needed, but just in case
4. edit passwd/shadow/group to add local users, hopefully you don’t have much and you remember who owned what to recover the ids
5. generate host keys like:
ssh-keygen -q -t rsa -f /etc/ssh/ssh_host_rsa_key -C ” -N ”
ssh-keygen -q -t rsa1 -f /etc/ssh/ssh_host_key -C ” -N ”
ssh-keygen -q -t dsa -f /etc/ssh/ssh_host_dsa_key -C ” -N ”
6. try to ssh to the host
7. repeat with strace until it works
8. get a lot of coffee and start to recover other stuff