Showing results for 
Search instead for 
Did you mean: 

sudo -s Logging

Regular Advisor

sudo -s Logging


I have setup winscp to sudo -s for a user.

I have setup the logging to send to the /var/log/sudo.log

the only entry i see in there is the sudo -s.

there after i do not see what the user is doing.

I have looked in /var/log/messages
as well.
where would this be logged?
Valued Contributor

Re: sudo -s Logging

Hi wayne,

from the man page:

-s [command]
The -s (shell) option runs the shell specified by the SHELL
environment variable if it is set or the shell as specified in
passwd(5). If a command is specified, it is passed to the shell
for execution. Otherwise, an interactive shell is executed.

So after the "sudo -s" has been executed without command, your are in the (root?) shell and the logs would be in the history file of the user.

If you are using bash, you can have it log all the commands in syslog.

Regular Advisor

Re: sudo -s Logging


thanks for the reply but it does not log to .bash_history

found a man that says that it wont but i am not so sure that it cannot be done.
Honored Contributor

Re: sudo -s Logging

Sudo by itself won't do it. It only logs the command started by sudo, nothing else. After the command is started, any further logging would have to be done by the command itself.

You would need one of the following:
- a modified shell that logs all commands, or
- kernel-level auditing that records the parameters of all commands executed, or
- a wrapper that records all the input and output of the privileged shell.

Sourceforge has "sudosh":

It acts as a wrapper between sudo and the shell and records all the input and output.
Instructions to configure it are in the README file within the sudosh source code package.

Once you have set up sudosh, you will have to change your winscp to use "sudo sudosh" instead of "sudo -s" (or replace the real "sudo" with a script that modifies the command line before the real "sudo" command is executed).

The sudosh package also includes "sudosh-replay", which allows you to view all recorded sudosh sessions in complete detail.

Honored Contributor

Re: sudo -s Logging

Use enhanced ksh (ksh93)?

That's how our systems aer set up... when an admin "sudo -s -E" to root -- all commands aer logged "elsewhere"

Hakuna Matata.