wip
This commit is contained in:
61
dots/bin/deploySshKeys.sh
Normal file → Executable file
61
dots/bin/deploySshKeys.sh
Normal file → Executable file
@@ -22,32 +22,45 @@ if ! [[ -d "$trg_ssh_dir" ]]; then
|
||||
mkdir -p ${trg_ssh_dir}
|
||||
fi
|
||||
|
||||
if ! [[ -f ${trg_ssh_dir}/*.pub ]]; then
|
||||
echo "deploy id_rsa.pub"
|
||||
cp ${src_ssh_dir}/*.pub ${trg_ssh_dir}
|
||||
else
|
||||
files=$(shopt -s nullglob dotglob; echo ${trg_ssh_dir}/*.pub)
|
||||
if (( ${#files} ))
|
||||
then
|
||||
echo "*.pub already exist in ${trg_ssh_dir}"
|
||||
else
|
||||
echo "deploy .pub file"
|
||||
cp ${src_ssh_dir}/*.pub ${trg_ssh_dir}
|
||||
fi
|
||||
|
||||
# if ! [[ -f ${trg_ssh_dir}/id_rsa.gpg ]]; then
|
||||
# echo "deploy id_rsa.gpg"
|
||||
# cp ${src_ssh_dir}/id_rsa.gpg ${trg_ssh_dir}
|
||||
# else
|
||||
# echo "id_rsa.gpg already exist in ${trg_ssh_dir}"
|
||||
# fi
|
||||
#
|
||||
# echo "do you want to decrypt id_rsa.gpg? (y/n)"
|
||||
# read user_input
|
||||
#
|
||||
# if [[ ${user_input} == "y" ]]; then
|
||||
# echo "yes"
|
||||
# echo "please, remember the hint: poq.l2"
|
||||
# gpg -d ${trg_ssh_dir}/id_rsa.gpg > ${trg_ssh_dir}/id_rsa
|
||||
# chmod 0600 ${trg_ssh_dir}/id_rsa # id_rsa can not be accessible by other users
|
||||
# else
|
||||
# echo "no worries. you can manually decrypt the file, if needed:"
|
||||
# echo "gpg -d id_rsa.gpg > id_rsa"
|
||||
# fi
|
||||
#
|
||||
files=$(shopt -s nullglob dotglob; echo ${trg_ssh_dir}/*.gpg)
|
||||
if (( ${#files} ))
|
||||
then
|
||||
echo "*.gpg already exist in ${trg_ssh_dir}"
|
||||
else
|
||||
echo "deploy .gpg file"
|
||||
cp ${src_ssh_dir}/*.gpg ${trg_ssh_dir}
|
||||
fi
|
||||
|
||||
echo "do you want to decrypt *.gpg? (y/n)"
|
||||
read user_input
|
||||
|
||||
if [[ ${user_input} == "y" ]]; then
|
||||
echo "yes"
|
||||
echo "please, remember the hint: poq.l2"
|
||||
|
||||
for file in ${src_ssh_dir}/*.gpg; do
|
||||
echo "processing '$file'"
|
||||
|
||||
filename="${file##*/}" # get basename
|
||||
filename="${filename%.*}" # remove extension
|
||||
|
||||
gpg -d ${trg_ssh_dir}/${filename}.gpg > ${trg_ssh_dir}/${filename}
|
||||
chmod 0600 ${trg_ssh_dir}/${filename} # id_rsa can not be accessible by other users
|
||||
done
|
||||
|
||||
else
|
||||
echo "no worries. you can manually decrypt the file, if needed. example command:"
|
||||
echo "gpg -d id_rsa.gpg > id_rsa"
|
||||
fi
|
||||
|
||||
echo "${trg_ssh_dir}:"
|
||||
ls -al ${trg_ssh_dir}
|
||||
|
||||
Reference in New Issue
Block a user