1
0
mirror of https://github.com/5im-0n/sshenc.sh.git synced 2025-08-02 11:20:05 +02:00

convert newer ssh keys to a format that openssl can understand

This commit is contained in:
gustavo panizzo
2020-02-27 01:43:29 +01:00
parent 53d26c4163
commit 845ad71fc4

View File

@@ -103,6 +103,9 @@ elif [[ -e "$private_key" ]]; then
stdin=`cat` stdin=`cat`
keys_enc=$(echo "$stdin" | awk '/-- keys/{f=1;next} /-- \/keys/{f=0} f') keys_enc=$(echo "$stdin" | awk '/-- keys/{f=1;next} /-- \/keys/{f=0} f')
cypher=$(echo "$stdin" | sed -e '1,/-- \/keys/d') cypher=$(echo "$stdin" | sed -e '1,/-- \/keys/d')
install -m 0600 "$private_key" "$temp_dir/private_key"
ssh-keygen -p -m PEM -N '' -f "$temp_dir/private_key"
i=0 i=0
while read line ; do \ while read line ; do \
@@ -116,9 +119,8 @@ elif [[ -e "$private_key" ]]; then
done <<< "$keys_enc" done <<< "$keys_enc"
decrypted=false decrypted=false
for key in "${keys[@]}" for key in "${keys[@]}"; do
do if ((echo "$key" | openssl base64 -d -A | openssl rsautl -decrypt -ssl -inkey "$temp_dir/private_key" >"$temp_file") >/dev/null 2>&1); then
if ((echo "$key" | openssl base64 -d -A | openssl rsautl -decrypt -ssl -inkey "$private_key" > "$temp_file") > /dev/null 2>&1); then
if echo "$cypher" | openssl base64 -d -A | openssl aes-256-cbc -pbkdf2 -iter 100000 -d -pass file:"$temp_file"; then if echo "$cypher" | openssl base64 -d -A | openssl aes-256-cbc -pbkdf2 -iter 100000 -d -pass file:"$temp_file"; then
decrypted=true decrypted=true
fi fi