moved key management draft into preflight function
This commit is contained in:
parent
a1d08207b4
commit
f758c29c00
88
sshbackup
88
sshbackup
|
@ -89,61 +89,51 @@ preflight()
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#if remote source or destination check for ssh key
|
#if there is a remote source or destination check for ssh key
|
||||||
if [[ $sourcepath =~ .*@.* ]] || [[ $destpath =~ .*@.* ]]; then
|
if [[ $sourcepath =~ .*@.* ]] || [[ $destpath =~ .*@.* ]]; then
|
||||||
#if [ -r $sshkeyfile ]; then
|
|
||||||
# #echo "sshkeyfile found. continuing."
|
#get executing user id
|
||||||
# :
|
local userid=$(id -u)
|
||||||
#else
|
|
||||||
# echo "aborting mission. no sshkey found."
|
#find out where executing users $HOME is
|
||||||
# return 1
|
while read line; do
|
||||||
#fi
|
line=$(echo $line | sed 's/ //g')
|
||||||
keymgmt
|
line=$(echo $line | sed 's/:/ /g')
|
||||||
|
if [ $(echo $line | awk '{print $3}') -eq $userid ]; then
|
||||||
|
local home=$(echo $line | awk '{print $6}')
|
||||||
|
fi
|
||||||
|
done < /etc/passwd
|
||||||
|
|
||||||
|
if [ -z $sshkeyfile ]; then
|
||||||
|
sshkeyfile="$home/.ssh/id_rsa"
|
||||||
|
fi
|
||||||
|
if [ -r $sshkeyfile ]; then
|
||||||
|
#ssh key found
|
||||||
|
:
|
||||||
|
else
|
||||||
|
if ( interactive ); then
|
||||||
|
echo "no ssh key found"
|
||||||
|
echo -e "do you want to create a ssh key pair? [y/n] \c"
|
||||||
|
read choice
|
||||||
|
if [ -z $choice ]; then
|
||||||
|
echo "aborting mission. no ssh key found."
|
||||||
|
return 1
|
||||||
|
elif [ $choice == "y" ] || [ $choice == "Y" ]; then
|
||||||
|
#creating ssh key pair
|
||||||
|
ssh-keygen
|
||||||
|
#TODO: key should also be deployed to remote side
|
||||||
|
return 1 #for now i'll break up here
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "aborting mission. no ssh key found."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
keymgmt()
|
|
||||||
{
|
|
||||||
#get executing user id
|
|
||||||
local userid=$(id -u)
|
|
||||||
|
|
||||||
#find out where executing users $HOME is
|
|
||||||
while read line; do
|
|
||||||
line=$(echo $line | sed 's/ //g')
|
|
||||||
line=$(echo $line | sed 's/:/ /g')
|
|
||||||
if [ $(echo $line | awk '{print $3}') -eq $userid ]; then
|
|
||||||
local home=$(echo $line | awk '{print $6}')
|
|
||||||
fi
|
|
||||||
done < /etc/passwd
|
|
||||||
|
|
||||||
if [ -z $sshkeyfile ]; then
|
|
||||||
sshkeyfile="$home/.ssh/id_rsa"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -r $sshkeyfile ]; then
|
|
||||||
#ssh key found
|
|
||||||
:
|
|
||||||
else
|
|
||||||
if ( interactive ); then
|
|
||||||
echo "no ssh key found"
|
|
||||||
echo -e "do you want to create a ssh key pair? [y/n] \c"
|
|
||||||
read choice
|
|
||||||
if [ -z $choice ]; then
|
|
||||||
echo "aborting mission. no ssh key found."
|
|
||||||
exit 1
|
|
||||||
elif [ $choice == "y" ] || [ $choice == "Y" ]; then
|
|
||||||
#creating ssh key pair
|
|
||||||
ssh-keygen
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
echo "aborting mission. no ssh key found."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
sshbackup()
|
sshbackup()
|
||||||
{
|
{
|
||||||
#creating local rsync options var
|
#creating local rsync options var
|
||||||
|
|
Reference in New Issue