4

Using the question here I can see the users connected with ssh. Is there a way to see (from terminal) what program the users connected with ssh are running?

EDIT The ssh users are running commands as sudo. and when I run ps aux it shows root as the user for those commands. Is there a way to see which of those are executed from ssh connected users?

1 Answers1

3

once you have pseudo terminal (e.g.pts/0 ), you can see all running programs, connected to pts/0, with

ps -f -t pts/0

or

ps -ft pts/0,pts/7,pts/12

for multiple tty (connected to 0, 7 and 12).

as in

archemar@abox:~/tmp7$ ps -t tty1,pts/2 -f

UID        PID  PPID  C STIME TTY          TIME CMD
root       313 64261  0 10:54 pts/2    00:00:00 sudo su -
root       314   313  0 10:54 pts/2    00:00:00 su -
root       321   314  0 10:54 pts/2    00:00:00 -su
root      1852     1  0 Nov12 tty1     00:00:00 /bin/login --
foo       2032  1852  0 Nov12 tty1     00:00:00 -bash
root      2046  2032  0 Nov12 tty1     00:00:00 sudo su -
root      2047  2046  0 Nov12 tty1     00:00:00 su -
root      2054  2047  0 Nov12 tty1     00:00:00 -su
archemar 64261 64260  0 09:13 pts/2    00:00:00 -bash
Archemar
  • 31,554
  • what is pseudo terminal? also I want specifically the ssh connected users, not all running processes I can find all processes using ps aux, but I want ssh specifically – John Demetriou Nov 30 '15 at 09:43
  • the ssh user is running commands as sudo, so the ps aux give me root as the user for those commands thus what you are giving me does not help me. edited my question to add this detail – John Demetriou Nov 30 '15 at 09:55