#!/bin/bash echo "DO_RSH version 09192k3-a(rsync)" echo "This version is for use with XINETD only!" echo "If you don't have XINETD (older Debian), you will have to modify " echo "/etc/inetd.d and related files manually." echo "Stage 0: Prep." function EXIT { echo "ABEND. Exiting due to error condition or user selection." echo "Error level will be set to $1" exit $1 } function CHECKHOST.UNTIES { cat /etc/hosts.unties echo '------------------------------------' echo 'Is this correct?' /usr/bin/ask if [ $? -ne 0 ]; then echo "No change was made." rm /etc/hosts.unties echo "Do you wish to exit now?" /usr/bin/ask if [ $? -eq 0 ]; then echo "Exiting while aborting edit of $1. Exit code is 4." EXIT 4 fi else echo Update complete. cp /etc/hosts.unties /etc/$1 fi } if [ -f /usr/bin/ask ]; then echo "Ask is already installed." else cp /root/bin/ask /usr/bin/ask fi echo "Stage 1. Making some backups." DATE=`date +%m%d%y.%H%M:%S` for i in deny allow equiv; do cp /etc/hosts.$i /etc/hosts.$i-$DATE done cp /etc/securetty /etc/securetty-$DATE echo "Stage 2a. Modifying HOSTS.ALLOW." cat /etc/hosts.allow >/etc/hosts.unties echo 'in.rshd : 192.168.1.' >>/etc/hosts.unties echo 'in.rlogind : 192.168.1.' >>/etc/hosts.unties echo 'portmap : 192.168.1.' >>/etc/hosts.unties echo 'sshd : 192.168.1.' >>/etc/hosts.unties echo 'rsync : 192.168.1.' >>/etc/hosts.unties CHECKHOST.UNTIES hosts.allow echo "Stage 2b. Modifying HOSTS.DENY." cat /etc/hosts.deny >/etc/hosts.unties echo 'ALL : ALL '>>/etc/hosts.unties CHECKHOST.UNTIES hosts.deny echo "Stage 2c. Making HOSTS.EQUIV." cat /usr/bin/do_ssh_hosts > /etc/hosts.unties CHECKHOST.UNTIES hosts.equiv echo "Stage 3. Modifying /ETC/SECURETTY." cp /etc/securetty /etc/hosts.unties echo "rsh" >>/etc/hosts.unties echo "rlogin" >>/etc/hosts.unties CHECKHOST.UNTIES securetty echo "Stage 4. Turning on the rsh and rlogin services." echo "NOTE: The following two commands will produce ERRORS." echo "on non-XINETD-based systems such as Debian Woody." chkconfig --level 345 rsh on chkconfig --level 345 rlogin on echo "Stage 5. Making it work for root." echo "=====================================" echo "| Are you sure you want to do this? |" echo "=====================================" /usr/bin/ask if [ $? -ne 0 ]; then echo "RSH is NOT enabled for root. Exiting with code 2." EXIT 2 fi scp /usr/bin/do_ssh_hosts /root/.rhosts echo ".RHOSTS added."