Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to use a simple command to count the number of ssh keys in a users home folder, but would rather use the output from the /etc/passwd file as input.

The find command is easy:

find /home/*/.ssh* -name id_* -exec printf '.' \;| wc -c

But I don't want to trawl directories that are no longer in use, so ideally I want to use the output from the line below to select specific active users only:

awk -F  ':' '{print $6}' < /etc/passwd

How do I do that?

share|improve this question

1 Answer 1

I would use a construct similar to this:

for f in `awk -F  ':' '{print $6}' < /etc/passwd`
do
  find /home/*/.ssh* -name id_* -exec printf '.' \;| wc -c
done
share|improve this answer
    
Are you counting the contents of ./ssh/authorized_keys? Those are public keys. –  jim mcnamara Aug 7 '13 at 2:18

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.