From 0237a4b281045a827e2c0177da6073f674d36828 Mon Sep 17 00:00:00 2001 From: PierreGode <8579922+PierreGode@users.noreply.github.com> Date: Tue, 14 Apr 2020 11:02:12 +0200 Subject: [PATCH] Added Password encryption Added Password encryption to generate encrypted password for automated joining with readfile encryption will genetate encrypted.dat > (your password encrypted) and private_key.pem public_key.pem all tree files are needed to decrypt the password. Find a way to get private_key.pem from outside source. Please do NOT store your private_key.pem with the other files untill the joining process. encrypt a password with sudo sh ADconnection.sh -p --- ADconnection.sh | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/ADconnection.sh b/ADconnection.sh index e0cd80c..95bea2c 100755 --- a/ADconnection.sh +++ b/ADconnection.sh @@ -1866,7 +1866,28 @@ exit fi exit } - +################################## encrypt pwd ############################### +encrypt(){ +echo "This will create 3 files public key, private key and encrypted file" +echo "make sure to store private file" +sudo openssl genrsa -out private_key.pem 2048 +sudo openssl rsa -in private_key.pem -out public_key.pem -outform PEM -pubout +echo "Please type password to encrypt" +stty -echo +read pass +echo "$pass" > encryptpwd.txt +stty echo +if [ -z "$pass" ] +then +echo "passwd is empty" +exit +else +sudo openssl rsautl -encrypt -inkey public_key.pem -pubin -in encryptpwd.txt -out encrypted.dat +sudo rm -rf encryptpwd.txt +ls +fi +exit +} ################################## info ################################## readmes(){ clear @@ -2053,6 +2074,14 @@ while test $# -gt 0; do exit 1 fi ;; + -p|--p) + if test $? -gt 0; then + encrypt + else + echo "" + exit 1 + fi + ;; -l|--l) if test $? -gt 0; then DATE=$(date +%H:%M)