LinuxQuestions.org
Help answer threads with 0 replies.
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 10-11-2015, 06:06 PM   #1
dewpoint
LQ Newbie
 
Registered: Oct 2015
Posts: 2

Rep: Reputation: Disabled
Hide SSH Terminal Script From User


Hello,

I am running the following script in /etc/bashrc to automatically record all terminal sessions to file on my server. (I regularly use contractors to install new scripts on my server, and have run into problems in the past where they have also installed disruptive scripts that redirect users, or other malicious scripts. I am hoping that by recording their activities, I can detect any malicious activities before they cause any harm).

test "$(ps -ocommand= -p $PPID | awk '{print $1}')" == 'script' || (script -f $HOME/$(date +"d-b-%y_%H-%M-%S")_shell.log)

When a user first logs in to my Linux server by ssh, they see the following:
Script started, file is /root/11-Oct-15_18-38-22_shell.log

My question is, is there any way to run this script without the user being notified that the script has been started?

Or perhaps another script that achieves the same without notifying the user?

Thanks for the help.

Last edited by dewpoint; 10-11-2015 at 08:19 PM.
 
Old 10-11-2015, 09:23 PM   #2
dewpoint
LQ Newbie
 
Registered: Oct 2015
Posts: 2

Original Poster
Rep: Reputation: Disabled
Figured it out. In case anyone else wants to do the same, simply add -q into the original command:

test "$(ps -ocommand= -p $PPID | awk '{print $1}')" == 'script' || (script -f -q $HOME/$(date +"d-b-%y_%H-%M-%S")_shell.log)
 
Old 10-11-2015, 09:27 PM   #3
Sefyir
Member
 
Registered: Mar 2015
Distribution: Linux Mint
Posts: 634

Rep: Reputation: 316Reputation: 316Reputation: 316Reputation: 316
You might want to let them know at some point that everything they do is recorded (just a imo)

You can also do this to redirect stdout/err messages

Code:
(command; command2) &> /dev/null
won't matter what happens then, all content that would be piped out will be sent to /dev/null. This shouldn't affect recording to shell.log however.
 
  


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
Using script to automatically record terminal sessions when a user logs in johnbolton Linux - General 10 02-22-2018 08:33 PM
How Hide user and machine information in terminal prompt kimreily Linux - Newbie 6 02-28-2012 09:41 AM
hide terminal window whn running script tank junior Linux - Newbie 1 03-14-2011 12:24 PM
Need Shell Script to allow user to connect to net through terminal Dralnu Linux - Networking 1 05-07-2006 09:31 AM
Simple shell script to open up terminal and ssh to another machine deadseasquirrel Programming 1 02-02-2006 05:25 AM

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

All times are GMT -5. The time now is 05:55 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
Open Source Consulting | Domain Registration