From 8a59d57b81abebfb9f513f6b9ca63ca002cb4a5f Mon Sep 17 00:00:00 2001 From: david Date: Sun, 7 Jul 2013 20:09:55 +0200 Subject: [PATCH] some final changes to oh_four --- README.md | 5 ++--- sshbackup | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 5e9b1e5..8650c8a 100644 --- a/README.md +++ b/README.md @@ -13,8 +13,7 @@ sudo chmod +x /usr/bin/sshbackup ### usage ```text -usage: sshbackup source destination [versions] -source/destination example: [[user@]server:]/path/to/files +usage: sshbackup [[user@]server:]/source/path /destination/path [versions] OPTIONS: -h, --help show this message @@ -25,7 +24,7 @@ OPTIONS: -s, --sshkey alternate sshkey [~/.ssh/id_rsa] -b, --bandwidth bandwidth limit in kbit/s - -d, --deploy deploy settings to remote host + -d, --deploy deploy settings to remote host -n, --no-root run without root privileges ``` diff --git a/sshbackup b/sshbackup index 2754f1c..4a3d081 100755 --- a/sshbackup +++ b/sshbackup @@ -134,7 +134,7 @@ deploy() echo "i will now attempt to create the user $user and apply all needed" echo "settings on following remote host: $machine" echo "in order to do so i need a sudo enabled username and" - echo "password on the remote host." + echo "password on the remote host. (hit Ctrl-C to abort)" echo -e "please enter your [sudo] username: \c" read username echo -e "please enter your [sudo] password: \c" @@ -149,6 +149,8 @@ deploy() eval pipewrap '$password' '$lockfile' | (sshpass -p "$password" ssh -q "$username@$machine" "sudo -S '$script'"; rm "$lockfile") sshpass -p $password ssh -q "$username@$machine" rm $script rm $script + #we will assume everything went fine + return 0 } preflight() @@ -168,8 +170,8 @@ preflight() return 1 fi - #TODO: check for dependencies and install them if necessary #check for dependencies + #TODO: and install them if necessary local deps="rsync cat ssh scp sshpass rm mv grep awk date tty id" local missingdeps="" local depscount="0" @@ -193,9 +195,8 @@ preflight() if [[ $sourcepath =~ .*@.* ]]; then #deactivate StrictHostKeyChecking for ssh client - #TODO: what if StrictHostKeyChecking is set but not to "no" if [ -r $HOME/.ssh/config ]; then - cat $HOME/.ssh/config | grep "StrictHostKeyChecking no" >> /dev/null + cat $HOME/.ssh/config | grep "StrictHostKeyChecking" >> /dev/null if [ $? -ne 0 ]; then echo "StrictHostKeyChecking no" >> $HOME/.ssh/config fi @@ -222,9 +223,15 @@ preflight() echo "aborting mission. error occured while creating ssh key pair" return 1 fi + echo -e "do you want to create a user and deploy this key now as well \c" + read choice + if [ -z $choice ]; then + echo "aborting mission. remote host must accept ssh key." + return 1 + elif [ $choice == "y" ] || [ $choice == "Y" ]; then #deploy key to remote system - deploy ${sourcepath%:*} $pubkeyfile - return 0 + deploy ${sourcepath%:*} $pubkeyfile + fi else echo "aborting mission. no ssh key found." return 1