LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 07-11-2010, 11:37 PM   #1
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Rep: Reputation: 110Reputation: 110
shell login tripwire?


I have disabled root login in my remote shell and I have a pretty strong password. I am not happy though. I want to increase security. I've been thinking about installing some basic tripwire rig, like say, send myself an email every time I (or anyone) log in. My questions:

- What kind of data would be useful to be sent in that email? Anything else besides "user so-and-so logged in at {date and time}"?

- How would I achieve that? Is it enough to include it in .tcshrc (because my shell is tcsh)? Should I add it to other shells as well (.bashrc, .csh etc.) even though nobody uses the other shells? Is it better placed in some other file, like .login? What is the optimal place?

- Would that be enough? Can I make that whole idea more secure in any way?
 
Click here to see the post LQ members have rated as the most helpful post in this thread.
Old 07-12-2010, 12:06 PM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
My .bash_profile has this
Code:
echo 'ALERT - Someone logged on to my account:' `date` `who` | mail -s "Alert: Someone logged in to my account! `who | awk '{print $6}'`" me@my-domain.com
It's worth putting a copy of that in roots profile too.
 
Old 07-12-2010, 03:16 PM   #3
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
I just realized... I can't put that tripwire thing in my .tcshrc (or .bash_profile). That would trigger the mechanism for EVERY NEW shell window, e.g. multiple windows in GNU Screen. I have to put that in some file that only triggers when I log in via SSH. What file would that be?
 
Old 07-12-2010, 04:36 PM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by lucmove View Post
I've been thinking about installing some basic tripwire rig, like say, send myself an email every time I (or anyone) log in. (..) Would that be enough?
Can you explain how you think that would actually make a system more secure?


Quote:
Originally Posted by lucmove View Post
I want to increase security.
What services does the machine provide? What have you done in terms of host hardening? Particularly access restrictions and "early warning" auditing?
 
Old 07-12-2010, 07:07 PM   #5
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
A warning email is useful to me because I get instant notification on my BlackBerry. Since I am sitting before the computer most of the time, I can check what's going on immediately.

The machine serves a Web site, email and sshd. I haven't done anything in terms of host hardening. I haven't done any auditing either.
 
Old 07-12-2010, 10:08 PM   #6
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Quote:
Originally Posted by lucmove View Post
I just realized... I can't put that tripwire thing in my .tcshrc (or .bash_profile). That would trigger the mechanism for EVERY NEW shell window, e.g. multiple windows in GNU Screen. I have to put that in some file that only triggers when I log in via SSH. What file would that be?
I don't get emails all the time, just when I log in. .bash_profile only gets executed at login.
 
Old 07-13-2010, 09:12 AM   #7
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by smoker View Post
I don't get emails all the time, just when I log in. .bash_profile only gets executed at login.
Try running GNU Screen and creating windows in it...
 
Old 07-13-2010, 09:54 AM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by lucmove View Post
A warning email is useful to me because I get instant notification on my BlackBerry. Since I am sitting before the computer most of the time, I can check what's going on immediately.
Exactly what I mean: after the fact.


Quote:
Originally Posted by lucmove View Post
The machine serves a Web site, email and sshd. I haven't done anything in terms of host hardening. I haven't done any auditing either.
Then you're doing things in reverse: the "must haves" (security basics and hardening) first. "Nice to haves" can be added at any time afterwards as they don't strengthen security posture like the first category.
 
Old 07-13-2010, 11:51 AM   #9
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 250Reputation: 250Reputation: 250
Quote:
Originally Posted by lucmove View Post
Try running GNU Screen and creating windows in it...
Nope, still no emails. Probably because I'm already logged in !

Last edited by smoker; 07-13-2010 at 11:53 AM.
 
Old 07-13-2010, 03:41 PM   #10
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by unSpawn View Post
Then you're doing things in reverse: the "must haves" (security basics and hardening) first. "Nice to haves" can be added at any time afterwards as they don't strengthen security posture like the first category.
What do you call "hardening"? I have disabled root login, only one user has access, the password is pretty good and sshd runs on an unusual port. What else do you suggest?

Something "after the fact" (but quite instantly) is a lot better than nothing after the fact at all.
 
Old 07-14-2010, 10:53 AM   #11
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by lucmove View Post
Something "after the fact" (..) is a lot better than nothing after the fact at all.
"After the fact" as in prevention is better than cure of course.


Quote:
Originally Posted by lucmove View Post
I have disabled root login,
You probably didn't even have to manually. It's the sane OpenSSH default.


Quote:
Originally Posted by lucmove View Post
only one user has access,
As in /etc/ssh/sshd_config AllowUsers / AllowGroups directives?
Or as in /etc/security/access.conf?
Or as in static IP range /etc/hosts.allow?


Quote:
Originally Posted by lucmove View Post
the password is pretty good and
Use passphrases instead?


Quote:
Originally Posted by lucmove View Post
sshd runs on an unusual port.
In the end that only fools "dumb" scanners.


But that's only part of it. Earlier on you said
Quote:
Originally Posted by lucmove View Post
The machine serves a Web site, email and sshd.
but "web site" can mean anything from static HTML to homebrewn CGI scripts to an off-the-shelf PHP-based CMS. In any case the machine sees more exposure than SSH alone. Any decent security tutorial should give you a checklist but minimally you would want to:
- remove software you don't run now or need now,
- set an install (review) and an update schedule where possible,
- don't run outdated, stale, vulnerable software,
- review access rights on setXid binaries,
- review mount flags where applicable,
- use a file integrity checker like Aide, Samhain or even tripwire,
- restrict human users (password criteria, account aging, ulimits, sudo, maybe network access restrictions),
- restrict processes (inert shell, run process as unprivileged user),
- restrict network access (sysctls, allowed ranges, blocking bogons, traffic limiting, blocking attempts with say fail2ban)
- make certain the system and all services log enough details,
- rotate logs often and keep enough archives and use a log reader like Logwatch to send you alerts (and read the reports!),
- audit the system regularly with GNU/Tiger and tools like that, and
* do check any changes you make preferably scanning from a remote location.
see the print version of the LQ Security FAQ at http://rkhunter.wiki.sourceforge.net/SECREF?f=print .
 
2 members found this post helpful.
Old 07-14-2010, 04:18 PM   #12
lucmove
Senior Member
 
Registered: Aug 2005
Location: Brazil
Distribution: Debian
Posts: 1,432

Original Poster
Rep: Reputation: 110Reputation: 110
Quote:
Originally Posted by unSpawn View Post
You probably didn't even have to [disable root login] manually. It's the sane OpenSSH default.
Not in Slackware, FYI. Slackware enables root login by default. Slackware rules.

I took note of your security checklist. Thank you.
 
0 members found this post helpful.
  


Reply



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
How to check in a script whether the shell is login or non login? frankie_DJ Programming 7 10-21-2015 10:09 AM
Difference between normal shell and login shell Manish Linux - General 7 11-14-2012 08:30 AM
How do I get the /etc/login.defs in a non login shell acummings Slackware 7 05-20-2007 10:17 PM
wrong login shell prevent root login cefs99 Linux - Security 4 05-31-2006 08:28 AM
tripwire reports /usr/sbin/tripwire changed alfaalfabeta Linux - Security 5 07-22-2003 05:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 03:35 AM.

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
Open Source Consulting | Domain Registration