Your best bet to show the active SSH sessions on a system is probably to combine the
netstat command with
netstat command is used to show statistics on network connections, not just limited to SSH. The
netstat command does require root privileges.
By piping the output of
grep you can filter connections properly to just list active SSH sessions. The command looks as follows:
$ sudo netstat -tnpa | grep 'ESTABLISHED.*sshd'
More generally, you can use the commands
w to list the currently logged in users on the system. Each displaying a different level of details.
users commands just displays a list of usernames separated by spaces.
$ users koen
$ who koen pts/0 Apr 18 16:28 (126.96.36.199)
$ w 16:28:47 up 21 days, 5:05, 1 user, load average: 0.30, 0.13, 0.07 USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT koen pts/0 188.8.131.52 16:28 7.00s 0.19s 0.01s w