commit 21599e3de1a7449b0072848fc48d91f7bf13f61f Author: Bret R. Human Date: Tue May 21 08:01:14 2019 -0400 initial commit diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..4dcfb95 --- /dev/null +++ b/LICENSE @@ -0,0 +1,51 @@ +trackdown +=== +Copyright (c) 2015, Bret R. Human +All rights reserved. + +Further documentation can be found at + https://psi.cynicaloptimist.me/Caffarius/trackdown/ +Happy modding! -Bret + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, + the documentation link and note, this list of conditions, and the following + disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. All advertising materials mentioning features or use of this + software must display the following acknowledgment: +"Built using software developed by Cynical Optimist - https://cynicaloptimist.me + Ask what we can build for you at info@cynicaloptimist.me" + +4. The names "Cynical Optimist" and "Bret R. Human" and the software name listed + at the top of this document, or the domain "cynicaloptimist.me" or any + affiliated service must not be used to endorse or promote products derived + from this software without prior written permission. For written permission, + contact info@cynicaloptimist.me. + +5. Products derived from this software may not be called the software name + listed at the top of this document nor may "Cynical Optimist" or the software + name listed at the top of this document appear in their names without prior + written permission of Bret R. Human. + +6. Redistributions of any form whatsoever must retain the following + acknowledgment: +"Built using software developed by Cynical Optimist - https://cynicaloptimist.me + Ask what we can build for you at info@cynicaloptimist.me" + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..24f7d54 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# trackdown + +A quick and dirty script to report if a user is present on a list of servers. \ No newline at end of file diff --git a/trackdown.sh b/trackdown.sh new file mode 100644 index 0000000..421095b --- /dev/null +++ b/trackdown.sh @@ -0,0 +1,54 @@ +#!/bin/bash +## Copyright © 2015 Bret Human +## https://cynicaloptimist.me/ +## +## Documentation at: +## https://psi.cynicaloptimist.me/Caffarius/trackdown +## +## For questions or comments write: +## info@cynicaloptimist.me +# +# Logs into every server and reports if a user is on it +# +# Prereq: Next to nothing. SSH? Bash? +# +# If you don't have an ssh key in your ~/.ssh folder this +# is going to be a loooooooooooooooooooooooooooooooooooooo +# ooooooooooooooooooooooooooooooooooooong process for you. + +usage () { + echo "usage: trackdown.sh -n username" + echo "You must specify a user to search for." + exit 1 +} + +# Get the username to hunt down. +while getopts "n:" option; do + case $option in + n) user=${OPTARG};; + esac +done + +if [ -z "$user" ]; then + usage +fi + +# Clean up any previous runs... +rm foundPlaces > /dev/null 2>&1 + +# File containing a list of servers to hit: +list="serverList" + +echo "Press CTRL-C to skip a server, CTRL-D to quit the script." +echo "" + +# Loop ALL the servers! +for thisHereServer in $(< "$list") ; do + trap "echo CTRL-C was pressed" 2 + trap "echo CTRL-D was pressed" 1 + + ssh $thisHereServer "id $user | grep uid" > /dev/null 2>&1 && + echo "$user found on $thisHereServer" && + echo "$user found on $thisHereServer" >> foundPlaces || + echo "Nothing on $thisHereServer" +done