From b37eb3270ecc14e0c91bec2db58ab042aecb6496 Mon Sep 17 00:00:00 2001 From: DarkFeather Date: Mon, 20 Feb 2017 09:49:46 -0600 Subject: [PATCH] New user support script --- Shared/Makefile | 2 +- Shared/replicate-ssh-profiles | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100755 Shared/replicate-ssh-profiles diff --git a/Shared/Makefile b/Shared/Makefile index 1d221cb..4900a46 100644 --- a/Shared/Makefile +++ b/Shared/Makefile @@ -1,4 +1,4 @@ -LIST=bell bigorlittle compare-directories compress-all diff-args expand-all logged-shell standardize-folder whatismyip new-irssi-config +LIST=bell bigorlittle compare-directories compress-all diff-args expand-all logged-shell standardize-folder whatismyip new-irssi-config replicate-ssh-profiles LOCATION=/usr/local/bin PERMISSION=0755 compile: diff --git a/Shared/replicate-ssh-profiles b/Shared/replicate-ssh-profiles new file mode 100755 index 0000000..ab3e8ea --- /dev/null +++ b/Shared/replicate-ssh-profiles @@ -0,0 +1,15 @@ +#!/bin/bash + +searchterm="$1" +if [ -z "$searchterm" ]; then searchterm="'*'"; fi +for system in `egrep '^Host ' $HOME/.ssh/config | cut -f 2 -d ' ' | egrep $searchterm`; do + printf "$system ... " + privfile="$(grep IdentityFile $HOME/.ssh/config | grep `echo $system | cut -f 1 -d '-'` | head -n 1 | cut -f 2 -d ' ')" + command='chmod 0700 $HOME $HOME/.ssh; echo "'`cat $privfile.pub`'" > $HOME/.ssh/authorized_keys; cp $HOME/.ssh/authorized_keys $HOME/.ssh/id_rsa.pub; chmod 0600 $HOME/.ssh/authorized_keys; chown -R `whoami` $HOME; mv $HOME/.profile $HOME/.profile.bak; mv $HOME/.bashrc $HOME/.bashrc.bak' + ssh $system bash -c "$command" + if [ $? -ne 0 ]; then printf "FAILED\n"; continue; fi + scp $privfile $system:.ssh/id_rsa + scp $HOME/.bashrc $system:.bashrc + scp $HOME/.profile $system:.profile + printf "DONE\n" +done