decrypt.sh 453 Bytes
Newer Older
ccarlos's avatar
ccarlos committed
1
2
#!/bin/bash

ccarlos's avatar
ccarlos committed
3
if [ ! -e ~/.ssh/slt2021_prv.pem ]
ccarlos's avatar
ccarlos committed
4
then
ccarlos's avatar
ccarlos committed
5
    echo "> Private key ~/.ssh/slt2021_prv.pem does not exist."
ccarlos's avatar
ccarlos committed
6
7
8
9
10
11
12
13
14
15
    exit 1
fi

notebookfile=$1

if [ ! -e "$notebookfile" ]
then
    echo "> Notebook file $notebookfile does not exist."
else
    openssl smime -decrypt -aes256 -in "$notebookfile" -binary -inform DEM \
ccarlos's avatar
ccarlos committed
16
        -inkey ~/.ssh/slt2021_prv.pem -out "${notebookfile%'.encr'}"
ccarlos's avatar
ccarlos committed
17
18
19
    
    echo "> File decrypted as ${notebookfile%'.encr'}"
fi