LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 11-02-2017, 04:03 AM   #1
luofeiyu
Member
 
Registered: Aug 2015
Posts: 220

Rep: Reputation: Disabled
Why can't record command containing ssh into /var/log/ssh.log?


Code:
vim /etc/profile
export HISTTIMEFORMAT="%Y-%m-%d:%H-%M-%S:  `whoami` : "
export PROMPT_COMMAND='history -a |grep ssh >> /var/log/ssh.log'
sudo touch /var/log/ssh.log
chmod 777 /var/log/ssh.log

Login with a normal user ,to input `cat /var/log/ssh.log` ,why no record in /var/log/ssh.log?
 
Old 11-02-2017, 04:58 AM   #2
luofeiyu
Member
 
Registered: Aug 2015
Posts: 220

Original Poster
Rep: Reputation: Disabled
export PROMPT_COMMAND='history |grep ssh >> /var/log/ssh.log'
 
Old 11-02-2017, 12:55 PM   #3
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.7.1908
Posts: 4,250

Rep: Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484Reputation: 1484
Quote:
Originally Posted by luofeiyu View Post
export PROMPT_COMMAND='history |grep ssh >> /var/log/ssh.log'
That just puts "history |grep ssh >> /var/log/ssh.log" into the environment variable PROMPT_COMMAND

To write to a file, just execute the command:
Code:
history  |grep ssh >> /var/log/ssh.log
PS. Setting perms on any file to 777 is almost never a good idea

Last edited by scasey; 11-02-2017 at 02:32 PM.
 
  


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
Why no log record in /var/log/mail.log? luofeiyu Linux - Server 2 10-06-2017 09:51 AM
Wrong incoming ssh ports in /var/log/auth.log ? electronicsguy Linux - Newbie 2 05-10-2015 04:02 PM
how to log ssh activity in /var/log/ssh/ssh*.log MrUmunhum Linux - Server 3 11-02-2011 03:25 AM
no ssh logging in /var/log/secure mberd Linux - Security 4 05-27-2009 08:55 AM
Can Samhain log my entries in /var/log/secure and /var/log/mesage to a central server abefroman Linux - Software 2 04-13-2008 05:13 PM

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

All times are GMT -5. The time now is 04:17 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration