Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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:

#!/bin/bash

srchGroup="$1"

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

# 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}"

$ ./show.group.users 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

 
discard

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.