Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a CentOS 5.5 server. How can I get a list of all the FTP users on the server using SSH?

share|improve this question
what FTP server do you have installed? – Feiticeir0 Jun 30 '11 at 18:26

First of all, there is no matter if you're doing this locally or remotely, since you will have shell access during the opened session anyway. If you want to just execute a single command on the remote machine and disconnect, you can specify it within quotes:

ssh user@machine 'echo "Who's your Daddy?"'

Nevertheless, you have few options to list all users within specific group:

Using getent tool:

getent group ftp

Old-fashion way:

grep ^ftp /etc/group

Using a home-brew script, which you can adapt to your own needs:



# get the corresponding line from /etc/group
for thisLine in "`grep "^${srchGroup}:" /etc/group`"
  # get the parts of interest 
  grpNumber="`echo ${thisLine} | cut -d":" -f3`"
  grpUsers="`echo ${thisLine} | cut -d":" -f4 | sed 's/,/ /g'`"

# check /etc/passwd
pwdUsers="`awk -F":" '$4 ~ /'${grpNumber}'/ { printf("%s ",$1) }' /etc/passwd`"

echo "0 ${srchGroup}" # given at commandline
echo "1 ${grpNumber}" # from /etc/group
echo "2 ${grpUsers}"  # from /etc/group
echo "3 ${pwdUsers}"  # from /etc/passwd
echo "All users: ${grpUsers} ${pwdUsers}"

$ ./ ftp
0 ftp
1 500
2 user1 user2
3 homie1 homie2
All users: user1 user2 homie1 homie2

This script been ripped from here.

share|improve this answer

In centos5, you're probably using vsftpd. See Logged on users in vsftpd

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.