Thursday, May 31, 2018

Bash script to run multiple AWS EC2 instance


Step 1: open vi <<filename>>.sh
Step2:  Enter the code as follows
a.  Add this code in the first line
#!/bin/bash
b.  Connect and run the comment with in the instance
ssh -i <<keyfile >> ec2-user@<<instance Ip>> << EOF
c.  Change user into root
sudo su -
d.  Write the comment you can to execute Eg
aws s3 sync <<S3 path>>  <<local path>>
e.  Exit from root
exit
f.  exit from instance
exit
EOF
Step3: Save and exit from editor
Setp4: provide a execute permission to created .sh file
      chmod +x <<filename.sh>>
Step 5: Run the file from terminal
   ./<<filename.sh>>

Installing ClamAV Antivirus in AWS EC2 instance


Following steps will help you to setup ClamAV virus scanner in AWS Ec2 instance
Step1 : Install ClamAV
Yum install clamav clamd
Step2 : Setup up log file folder
a.       Create a new folder clamd under /var/log
b.       Provide a read write access to clamscan user
chown -R clamscan:clamscan /var/log/clamd/
Step3: If you are trying to use socket.
            a.       Create a  clamd.scan folder under /var/run
            b.       Provide a read and write access to clamscan user
chown -R clamscan:clamscan /var/run/clamd.scan/
Step4: Setup Configuration
a.       Edit the configuration file available in
vi /etc/clamd.d/scan.conf
b.       To enable logging un comment LogFile and change the path
LogFile /var/log/clamd/clamd.log
c.       If you are using Socket un comment LocalSocket and change the path
                                LocalSocket /var/run/clamd.scan/clamd.sock
d.       If you are tying to TCP port uncomment TCPSocket
Step5:  run sed -i '/^Example$/d' /etc/clamd.d/scan.conf
Step 6  Start service
                service clamd.scan start