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
This commit is contained in:
PierreGode 2020-04-14 11:02:12 +02:00 committed by GitHub
parent c2f67ff05d
commit 0237a4b281
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)