Link to home
Start Free TrialLog in
Avatar of hankknight
hankknightFlag for Canada

asked on

Show FTP Users currently logged in

I want to know the usernames and IP addresses of all FTP users currently logged in.

I use vsftpd on CentOS5.
Avatar of pawwa
pawwa
Flag of Serbia image

You can add the following directives in your vsftpd.conf

setproctitle_enable=YES
session_support=YES

Then reload the service:

# service vsftpd reload

and now you can see connected users and their IP addresses with process listing:

# ps aux | grep vsftpd | grep -v grep
Avatar of hankknight

ASKER

Thanks but that shows other usres as well, such as root and nobody who are NOT connected with FTP.  I only want the usernames and IP addresses of all FTP users currently logged in to FTP.
Avatar of haswandi
haswandi

who | grep -i ftp
ASKER CERTIFIED SOLUTION
Avatar of pawwa
pawwa
Flag of Serbia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks.

haswandi, your idea returns an empty result even when FTP users are logged in.

pawwa,  this just returns 0:00
ps aux | grep vsftpd | grep -v grep | fmt -u | cut -d " " -f 12 | sed -e "s/\(.*\)\/\(.*\):/\1 \2/" | grep "^[[:digit:]]"
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hmmm, strange, I've tested yesterday those combined commands on my server, and it has successfully shown the users and their IPs, but you are right the commands are wrong,  (because of the fmt -u).

Anyway, I modified the commands, so it should be like this:

# ps aux | grep vsftpd | grep -v grep | tr -s " " | cut -d " " -f 12 | sed -e "s/\(.*\)\/\(.*\):/\1 \2/" | grep "^[[:digit:]]" | grep "[[:alnum:]]$"

I run this as root at it gives me IP USER formatted output.

BTW, haswandi's solution (who | grep -i ftp) is nicer, but I don't know why it won't give you any output (I guess you have setproctitle_enable=YES in your vsftpd.conf?).