Avatar of Joe_Pritchard
Flag for United Kingdom of Great Britain and Northern Ireland

asked on 

unable to list current users logged in via SFTP client


I have an SFTP server running on a Debian box, used for clients to upload data and other files to us. I've got a script running which picks up those files and delivers them to a windows server share for the office staff to pick up. My problem is this:

I'd like to add a little routine in the script to check whether the client is currently logged in (so potentially in the process of uploading files) before moving said files away and risking grabbing one that hasn't been completely transfered. I tried doing it with the following lines in my script:

logontest=$(ps auwx | grep -v grep | grep "username" | wc -l)

if [ $logontest -gt 0 ]; then

exit 0

Open in new window

which would work in theory, but when this particular client connects, for some reason I don't get him listed in the output from ps. I see his login in auth.log, but he doesn't spawn a "username"@notty process or anything. Now I've connected as this user (using filezilla from another machine) and checked that I definitely do show up in ps, so it may be something peculiar about the software they're using (SecureCRT form a windows box AFAIK)

Just wondering if anyone can suggest a way to resolve this, or another way to check for a current connection from this user (using his IP or something?)

Shell ScriptingSSH / Telnet SoftwareLinux Networking

Avatar of undefined
Last Comment

8/22/2022 - Mon