Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 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

I would use a construct similar to this:

for f in `awk -F  ':' '{print $6}' < /etc/passwd`
  find /home/*/.ssh* -name id_* -exec printf '.' \;| wc -c
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


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.