passphrase

This commit is contained in:
Marc Beninca 2024-11-12 09:28:08 +01:00
parent 671beb4b0e
commit fe5c75b142
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F
3 changed files with 26 additions and 8 deletions

View file

@ -9,8 +9,7 @@ rescue_wipe_0_init_hetzner_8_8() {
local passphrase local passphrase
local unit='mib' local unit='mib'
# read passphrase # read passphrase
echo -n 'PassPhrase: ' passphrase="$(read_passphrase)"
read -r -s passphrase
# #
lsblk lsblk
echo -n 'WIPE' "${devices[@]}" '/?\ OR CANCEL /!\' echo -n 'WIPE' "${devices[@]}" '/?\ OR CANCEL /!\'
@ -149,6 +148,8 @@ rescue_wipe_0_init_hetzner_8_8() {
# open # open
echo "${passphrase}" | echo "${passphrase}" |
cryptsetup luksOpen '/dev/md/crypt' 'crypt' cryptsetup luksOpen '/dev/md/crypt' 'crypt'
# passphrase
unset passphrase
} }
rescue_wipe_2_make_hetzner_8_8() { rescue_wipe_2_make_hetzner_8_8() {
@ -156,8 +157,7 @@ rescue_wipe_2_make_hetzner_8_8() {
# close # close
cryptsetup luksClose 'crypt' cryptsetup luksClose 'crypt'
# read passphrase # read passphrase
echo -n 'PassPhrase: ' passphrase="$(read_passphrase)"
read -r -s passphrase
# encrypt # encrypt
echo "${passphrase}" | echo "${passphrase}" |
cryptsetup \ cryptsetup \
@ -175,6 +175,8 @@ rescue_wipe_2_make_hetzner_8_8() {
# open # open
echo "${passphrase}" | echo "${passphrase}" |
cryptsetup luksOpen '/dev/md/crypt' 'crypt' cryptsetup luksOpen '/dev/md/crypt' 'crypt'
# passphrase
unset passphrase
# format crypt # format crypt
mkfs.btrfs --force \ mkfs.btrfs --force \
--checksum 'sha256' \ --checksum 'sha256' \

View file

@ -3,8 +3,7 @@ rescue_wipe_0_init_ovh_vle2() {
local passphrase local passphrase
local unit="mib" local unit="mib"
# read passphrase # read passphrase
printf "PassPhrase: " passphrase="$(read_passphrase)"
read -r -s passphrase
# warn # warn
lsblk lsblk
printf "%s" "WIPE ${device} /?\\ OR CANCEL /!\\" printf "%s" "WIPE ${device} /?\\ OR CANCEL /!\\"
@ -78,6 +77,8 @@ rescue_wipe_0_init_ovh_vle2() {
# crypt / open # crypt / open
echo "${passphrase}" | echo "${passphrase}" |
cryptsetup luksOpen "${device}1" "crypt" cryptsetup luksOpen "${device}1" "crypt"
# passphrase
unset passphrase
} }
rescue_wipe_2_make_ovh_vle2() { rescue_wipe_2_make_ovh_vle2() {
@ -86,8 +87,7 @@ rescue_wipe_2_make_ovh_vle2() {
# crypt / close # crypt / close
cryptsetup luksClose "crypt" cryptsetup luksClose "crypt"
# read passphrase # read passphrase
printf "PassPhrase: " passphrase="$(read_passphrase)"
read -r -s passphrase
# crypt / encrypt # crypt / encrypt
echo "${passphrase}" | echo "${passphrase}" |
cryptsetup \ cryptsetup \
@ -105,6 +105,8 @@ rescue_wipe_2_make_ovh_vle2() {
# crypt / open # crypt / open
echo "${passphrase}" | echo "${passphrase}" |
cryptsetup luksOpen "${device}1" "crypt" cryptsetup luksOpen "${device}1" "crypt"
# passphrase
unset passphrase
# crypt / format # crypt / format
mkfs.btrfs --force \ mkfs.btrfs --force \
--checksum "sha256" \ --checksum "sha256" \

View file

@ -5,3 +5,17 @@ not() {
*) ;; *) ;;
esac esac
} }
read_passphrase() {
read_secret "PassPhrase: "
}
read_secret() {
local prompt="${1}"
local secret
printf "${prompt}" 1>&2
read -r -s secret
echo >&2
echo "${secret}"
unset secret
}