Yasiru G
Yasiru G

Reputation: 7144

How to log command in ssh sessions?

I have a debian server which users ssh to it and do telnet sessions on it. My requirement is log all the users commands executions and also the commands run in the telnet sessions.

I found script software while searching for a solution for this and it do what I want.

I tried testing it by adding following line to /home/username/.profile but it runs 2 script processes and need to run exit twice to exit from ssh session.

Log commands in each session
if [[ -n $SSH_CONNECTION ]] ; then
    script test.txt
fi

Is anyone know why is this happen or how to fix it, or better solution for this?

Thank you!

Upvotes: 0

Views: 161

Answers (1)

Ipor Sircer
Ipor Sircer

Reputation: 3141

Use exec:

exec script test.txt

Upvotes: 2

Related Questions