LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 03-03-2010, 04:33 PM   #1
johnbolton
LQ Newbie
 
Registered: Mar 2010
Location: San Diego, CA
Posts: 7

Rep: Reputation: 1
Question Using script to automatically record terminal sessions when a user logs in


I'm trying to set up automatic recording of user sessions when they login without their knowledge. I tried sticking the script command into /etc/profile and but that didn't really work. I also tried /etc/bashrc but that had the same affect.

I have also tried setting the shell in /etc/passwd to SHELL=/bin/bash /usr/bin/script -q /testing.txt.

I'd appreciate any suggestions. Also, I don't have to use the script utility; this is the only command I am aware to accomplish this task.

Thanks,

John
 
Old 03-03-2010, 08:04 PM   #2
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
Why don't you just cat the users .bash_history to a file ? Or sym-link each users history to a file elsewhere ?
 
Old 03-03-2010, 08:18 PM   #3
archShade
Member
 
Registered: Mar 2006
Location: Delft NL
Distribution: Debian; Slackware; windows 7
Posts: 218

Rep: Reputation: 53
If you need to know what commands a user has used why not read there bash history (/home/<user>/.bash_history) it wont tell you the out put they got from the commands but you should be able to work it out (after all if you can change /etc/passwd bashrc you should be able to read user files.

also why not just add the script command to the users /home/<user>/.bashrc file.

can you expand on "didn't really work"?
 
Old 03-03-2010, 10:21 PM   #4
John VV
Guru
 
Registered: Aug 2005
Posts: 12,600

Rep: Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677
First WE WILL NOT help you do anything illegal

this sounds a lot like a password sniffer .
 
Old 03-03-2010, 10:39 PM   #5
johnbolton
LQ Newbie
 
Registered: Mar 2010
Location: San Diego, CA
Posts: 7

Original Poster
Rep: Reputation: 1
Quote:
First WE WILL NOT help you do anything illegal
That is about the dumbest thing I have ever heard. First of all the script command will not show hidden characters, like most password prompts. Second of all, this isn't illegal. I want to see what users are doing in order to properly troubleshoot and debug their problems.

Quote:
Why don't you just cat the users .bash_history to a file ?
Because I want screen output as well as the commands.

When I added the command to /etc/bashrc, upon startup, the shell was logged in automatically. Obviously this is a problem.

Quote:
also why not just add the script command to the users /home/<user>/.bashrc file.

can you expand on "didn't really work"?
After adding the command to the .bashrc file, I attempted to su to that user and then the box nearly hung. Somehow hundreds of bash processes were spawned. Pretty scary.

Thanks,

John
 
Old 03-03-2010, 11:54 PM   #6
John VV
Guru
 
Registered: Aug 2005
Posts: 12,600

Rep: Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677Reputation: 1677
"That is about the dumbest thing I have ever heard. First of all the script command will not show hidden characters, like most password prompts"
--
no but a key logger will

"I want to see what users are doing in order to properly troubleshoot and debug their problems."

that would have been nice to know in the first post
but the log files do a great job of this

"Because I want screen output as well as the commands."
a screen shot?


you can always remote login as root
 
Old 03-04-2010, 06:05 AM   #7
smoker
Senior Member
 
Registered: Oct 2004
Distribution: Fedora Core 4, 12, 13, 14, 15, 17
Posts: 2,279

Rep: Reputation: 248Reputation: 248Reputation: 248
So you're not automatically recording terminal sessions then, you want to record desktop sessions. This has nothing to do with bash. But your attitude stinks so goodbye.
 
Old 03-04-2010, 10:12 AM   #8
johnbolton
LQ Newbie
 
Registered: Mar 2010
Location: San Diego, CA
Posts: 7

Original Poster
Rep: Reputation: 1
Quote:
So you're not automatically recording terminal sessions then, you want to record desktop sessions. This has nothing to do with bash. But your attitude stinks so goodbye.
X-Windows has nothing to do with this. This is strictly bash. And I don't think my attitude stinks.

My company sells hardware with our software installed. We provide shell access to the users in case they need to configure stuff that isn't handled by the web interface.

We want to collect all screen output of the users logins and interaction with the shell and store it to a file so that it can be looked at in case something goes wrong and we suspect they did something they should not have.

Quote:
a screen shot?
It has to be automated. Screenshots aren't going to cut it.

Quote:
you can always remote login as root
No, that isn't going to work either.

It would be nice to get a answer to my question regarding the use of script. Does anybody know how to turn it on when a user logs in without their knowledge? We're not trying to be sneaky here. We simply want to avoid users calling in and asking questions like "what does script started mean"?

Thanks,

John
 
Old 03-04-2010, 10:52 AM   #9
johnbolton
LQ Newbie
 
Registered: Mar 2010
Location: San Diego, CA
Posts: 7

Original Poster
Rep: Reputation: 1
Solved

I figure I'd post my solution...

Create a script in the home directory:

/home/user/login.sh
Code:
#!/bin/bash
SHELL=/bin/bash script -q /home/user/console.log
Change the shell in /etc/passwd to the script:

Code:
user:x:1001:100::/home/user:/home/user/login.sh
Now when the user logs all console output will be written to the log file.

John
 
  


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
record of user sessions PirateJack Linux - Newbie 5 04-03-2006 02:25 PM
Start X automatically when user logs in? Firewielder Linux - Newbie 4 01-21-2006 10:00 AM
I want to automatically run a program when a user logs on their account bad_andy Linux - Newbie 7 02-01-2005 08:55 PM
how to get citrix automatically started up when a user logs in. sjel Linux - Newbie 2 09-06-2004 08:40 AM
Getting vncserver to run automatically when user logs in indespair Linux - Networking 2 10-26-2003 02:37 AM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration