Skip to content

Instantly share code, notes, and snippets.

@jkerian
Forked from anonymous/correlate_jail_users
Last active February 6, 2018 21:05
Show Gist options
  • Save jkerian/329026d454b76c3b1de723b93c24130d to your computer and use it in GitHub Desktop.
Save jkerian/329026d454b76c3b1de723b93c24130d to your computer and use it in GitHub Desktop.
#!/bin/sh
# Quick script to show all jail users and how they coordinate with main box userlist
for uid in $(awk 'FS=":" {if ($0!~/^\#/) {print $3}}' /usr/jails/*/etc/passwd /etc/passwd | sort -n | uniq); do
echo -n "$uid "
awk 'FS=":", ORS=" " {if ($0!~/^\#/ && $3=='$uid') {print "[" $1 "]"; if ($7=="/usr/sbin/nologin") {print "(#nologin)"}}}' /etc/passwd
awk 'FS=":", ORS=" " {if ($0!~/^\#/ && $3=='$uid') {print FILENAME ":" $1; if ($7=="/usr/sbin/nologin") {print "#"}}}' /usr/jails/*/etc/passwd | sed -E 's|/usr/jails/||g' | sed -E 's|/etc/passwd||g'
echo ""
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment