RHEL 6 Hardening with shell scripts
I'm a Systems Administrator; but I'm new to Shell Scripting. I have a task of hardening quite a number of servers - more than 20. To reduce the work load, I thought of writing shell scripts that would automate most of the things to be done. The organization wants the CIS Benchmark for RHEL 6 to be followed. I wrote 2 scripts, and tried running them. But it seems they are not working. I get the error the following errors:
-bash command not found --when I execute the script with its name. I did the chmod +x
the script runs when I run it with: sh script.sh
but I get these issues:
in /etc/fstab or /etc/tab
usage chkconfig [--list] [--type ] [name] ---shows me usage of chkconfig
Here is my script. what am I doing wrong ?
#!/bin/bash # Title: RHEL 6 Hardening # Author: Oageng Escobar Baruti # Date: 24/08/2015 # # DESCRIPTION: DISABLE / REMOVE / STOP / START / CONFIGURE # # Configure File Systems cp /etc/fstab /etc/fstab.`date +%d%m%Y_%H:%M.%S` mount -o remount,nodev /tmp mount -o remount,nosuid /tmp mount -o remount,noexec /tmp mount --bind /tmp /var/tmp mount -o remount,nodev /home mount -o remount,nodev /dev/shm mount -o remount,nosuid /dev/shm mount -o remount,noexec /dev/shm # # Disable / Stop Unneccessary Services / Daemons chkconfig rhnsd off chkconfig chargen-dgram off chkconfig chargen-stream off chkconfig daytime-dgram off chkconfig daytime-stream off chkconfig echo-dgram off chkconfig echo-stream off chkconfig tcpmux-server off chkconfig avahi-daemon off chkconfig cups off chkconfig nfslock off chkconfig rpcgssd off chkconfig rpcbind off chkconfig rpcidmapd off chkconfig rpcsvcgssd off # # # Start Important Services # # # Remove Uncessary / Unneeded Packages / Programs yum erase mcstrans yum erase telnet-server yum erase telnet yum erase rsh-server yum erase rsh yum erase ypbind yum erase ypserv yum erase tftp yum erase tftp-server yum erase talk yum erase talk-server yum erase xinetd yum erase dhcp yum erase openldap-servers yum erase openldap-clients yum erase bind yum erase vsftpd yum erase httpd yum erase dovecot yum erase samba yum erase squid yum erase net-snmp yum erase setroubleshoot yum remove xorg-x11-server-common # # Configure Networking / Firewalls #chkconfig iptables on chkconfig iptables off chkconfig ip6tables off # # yum install tcp_wrappers #
Responses