How can I see if users are logged in over sftp?

You can also do:

ps -ef | grep '[s]shd' | grep -v ^root

which should show any sshd sessions (which are used for sftp). I notice on my machine my sshd process command line contains '$USER@notty' which makes sense since I'm not logged in with a terminal session. You could tighten up the grep above with:

ps -ef | grep '[s]shd:.*@notty' | grep -v ^root

BTW: the square brackets in the grep are to not have the 'grep sshd' process show up in the process list. [s]shd matches sshd, but doesn't match itself. It saves a 'grep -v grep'


You could also try fuser -u ssh/tcp


I think you can use the command line program who to see this. I have noticed some reports that doing so doesn't work, but I still think it may work (maybe it's an ssh setting).

sftp is built on top of SSH. It stands for the "SSH File Transfer Protocol". And when you're logged in over ssh, 'who' will include you as a logged in user with its output. So I'd expect this to work with active sftp sessions too.

This discussion from 2008 also suggests that you may use 'netstat' for this. It also includes a suggestion to run 'who' via 'watch' so you can see updates without doing anything.