LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-17-2010, 12:03 AM   #1
fugitivemind
LQ Newbie
 
Registered: Sep 2010
Posts: 2

Rep: Reputation: 0
How can I create an automated shell script


Greetings to all, I am a complete newbie to linux. I am currently taking a course at Devry university called netw240. I am in my 2nd week of class and am required to turn in a paper at the end of the coures were I write an automated shell script. I am currently using Fedora 12 on a Vmware player and want to try to write a script that automates the process of Logging user login activity to detect unauthorized remote access attempts.

I am looking for pointers on were to start, examples, ect.. anything that can get me started. Also, is this type of script to much for a beginner?
 
Old 09-17-2010, 12:06 AM   #2
quanta
Member
 
Registered: Aug 2007
Location: Vietnam
Distribution: RedHat based, Debian based, Slackware, Gentoo
Posts: 724

Rep: Reputation: 100Reputation: 100
Have a look at /var/log/secure.
 
Old 09-17-2010, 12:36 AM   #3
prayag_pjs
Senior Member
 
Registered: Feb 2008
Location: Pune - India
Distribution: Fedora,RedHat,CentOS,Gentoo
Posts: 1,145
Blog Entries: 4

Rep: Reputation: 147Reputation: 147
Thumbs up

grep -i 'authentication failure' /var/log/messages
 
Old 09-17-2010, 12:48 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
Also google PAM & fail2ban
 
1 members found this post helpful.
Old 09-17-2010, 02:11 AM   #5
kiyohira
LQ Newbie
 
Registered: Sep 2010
Posts: 1

Rep: Reputation: 0
Need to know:

* Where the log file is?
-> /var/log/*

* How to extract needed information?
-> Use grep command

* How to run the script automatically?
-> Use cron, google "crontab manpage" for usage

May require several hours to one day for newbie.
 
Old 09-17-2010, 02:35 AM   #6
vinaytp
Member
 
Registered: Apr 2009
Location: Bengaluru, India
Distribution: RHEL 5.4, 6.0, Ubuntu 10.04
Posts: 704

Rep: Reputation: 55
Quote:
Originally Posted by prayag_pjs View Post
grep -i 'authentication failure' /var/log/messages
Hope it has to be

Code:
grep -i 'authentication failure' /var/log/secure
 
Old 09-17-2010, 04:05 AM   #7
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 113Reputation: 113
simple way is use /var/log/secure file.

You can also use PAM as suggested chrism01. Through pam you can record fail user login attempt.

Regards,
 
Old 09-17-2010, 11:57 PM   #8
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 12,852
Blog Entries: 18

Rep: Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337
Garrrell's BASH scripting manual.

Automated could mean making it a cron job which is easy, or causing it to be triggered by an event, which I am not competent to help you with.
 
Old 09-23-2010, 12:08 AM   #9
fugitivemind
LQ Newbie
 
Registered: Sep 2010
Posts: 2

Original Poster
Rep: Reputation: 0
Thank's for the replys everyone, but I am still in the dark.
 
Old 09-23-2010, 12:32 AM   #10
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,417

Rep: Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397Reputation: 2397
In that case show us what you've got done so far. Also, simplify your design to the bare minimum and get that working first (K.I.S.S).
You can add to it later.
 
Old 09-23-2010, 10:40 PM   #11
frankbell
LQ Guru
 
Registered: Jan 2006
Location: Virginia, USA
Distribution: Slackware, Debian, Mageia, and whatever VMs I happen to be playing with
Posts: 12,852
Blog Entries: 18

Rep: Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337Reputation: 3337
This may be redundant, but there are two issues here:

1. Creating and testing the script.

2. Automating it.

Make sure step 1 is complete before moving on to step 2.
 
Old 09-24-2010, 12:33 PM   #12
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
... and before you write the script you could explore the commands for use in the script at the command prompt.

Last edited by catkin; 09-24-2010 at 12:33 PM. Reason: line -> prompt
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell automated patchign script wondergirl Programming 2 02-20-2008 06:02 PM
automated FTP shell script RedOctober45 Linux - Software 1 01-09-2008 09:58 AM
Automation Script !! Create automated archive of files based on name of file! yoshima Programming 5 09-28-2007 06:17 AM
how can create shell script user52 Linux - Newbie 4 11-27-2006 12:16 PM
how create shell script user52 Linux - General 1 11-27-2006 04:35 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:38 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration