15

If someone logs into a server via ssh for shell usage, a quick use of last|w|who can be used to show the logged in user. If someone mounts a directory on the same server via sshfs from another computer last|w|who do not show a connection. Is there a command similar to last|w|who which will show current sshfs mounts on a server?

M. Smith
  • 153
  • 1
  • 1
  • 4

1 Answers1

18

Making an sshfs mount involves connecting across sftp. Hence, what you can do is look for the spawned sftp processes. Assuming the user andreas has made an sshfs mount, or logged in using regular sftp, you'll see something along the following lines:

root@halleck:~# ps aux | grep -i sftp | grep -v grep
andreas  11029  0.0  0.0   2420   648 ?        Ss   23:56   0:00 /usr/lib/openssh/sftp-server
root@halleck:~#

alt.

root@halleck:~# ps aux | grep -i sftp | grep -v grep
andreas  11091  0.0  0.1   9564  1116 ?        Ss   23:57   0:00 sshd: andreas@internal-sftp
root@halleck:~#

What you see depend in what sftp Subsystem you have configured.

The details in this answer assumes OpenSSH server side.

andol
  • 6,848
  • 28
  • 43
  • 1
    Thanks Andol, this is the method that I currently use. I know that I could alias this type of a command and use the alias quickly. I was wondering if there were any widely used utils out there that had this type of listing built into it. – M. Smith Jul 13 '12 at 00:29