0

To set the specified sshd log file in ssh server pc this way.

vim /etc/rsyslog.conf
local0.*     /var/log/sshd.log 
vim /etc/ssh/sshd_config
SyslogFacility local0

To create the log file:

touch /var/log/sshd.log

To restart all services.

systemctl restart rsyslog
systemctl restart sshd

To get all the ssh log in ssh client pc this way.

sudo vim /etc/bash.bashrc
HISTTIMEFORMAT="%Y-%m-%d:%H-%M-%S:whoami: "
export HISTTIMEFORMAT
PROMPT_COMMAND='history -a'      
source /etc/bash.bashrc

Now to get all ssh log record.

history |grep  ssh  

My question is that how to set the specified ssh log file in ssh client pc,instead of sshd log file in ssh server pc?

Here is my try in ssh client pc.

vim /etc/rsyslog.conf
local0.*     /var/log/ssh.log 
vim /etc/ssh/ssh_config
SyslogFacility local0

To create the log file:

touch /var/log/ssh.log

To restart all services.

systemctl restart rsyslog
reboot

An error occur when to login my vps from ssh client pc:

/etc/ssh/ssh_config: line 56: Bad configuration option: syslogfacility
/etc/ssh/ssh_config: terminating, 1 bad configuration options

Is there a way to set the specified ssh log file in ssh client pc instead of logging it in history?
History command can log all the ssh action taken in my ssh client pc,i want all the log info in a single specified file such as /var/log/ssh.log.
Please don't tell me this way.

history |grep  ssh  >> /var/log/ssh.log
4
  • You want to log ... the shell commands? ... of the remote session on the local side?
    – Jeff Schaller
    Commented Nov 2, 2017 at 2:07
  • To log all ssh action taken in the ssh client pc on a ssh.log file in the ssh client pc.
    – scrapy
    Commented Nov 2, 2017 at 2:09
  • is the client OpenSSH? I know that PuTTY, for example, lets you set up a local log file.
    – Jeff Schaller
    Commented Nov 2, 2017 at 2:10
  • The client os is debian ,client soft is openssh.
    – scrapy
    Commented Nov 2, 2017 at 2:12

1 Answer 1

0

Do the following on the client:

script logfile.log
ssh into the machine
do whatever you need
exit from ssh
exit from script

It will log everything that happens inside the script session to the file specified at the beginning until you exit.

Beware of commands that manipulate the whole screen (vi, top, etc...) as they will generate garbage to the log.

2
  • My companion can't do it,so it is not a good idea.
    – scrapy
    Commented Nov 2, 2017 at 6:26
  • I know this is not a perfect solution, but given your previous info it does the job. Can you tell what's wrong so I'm able to try to fix? Maybe I can even think of something different...
    – Zip
    Commented Nov 2, 2017 at 13:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .