Commit 3aaf35f8 authored by Dillenn Terumalai's avatar Dillenn Terumalai
Browse files

Created the correct key for SPSP SFTP and automated pipeline is working

parent 285caa82
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBF0xzeABEAC7Qcq4NY8bI4TsGIZRNJWOZb8mLlPDwFdVCzyIj8PPsfs4kFc3
1e6xMEfWMO39qACMsta3R2MAsxxbwOjWmiK398pmpZjGX+/RuCH2Frczr9Pl3xFv
+eZJqThlSYh0x1cl+7kgxo1Ac1R/+ixk0PfPdnidCGMMn5GT188l7PfqVSax/Wnx
ChHzGA5svbkrFR3C2OarxP5hcusuOe/5yfZ1p6ZjhV7vdGzLx+6PytpBSzz0alMm
5MoA8GfLMKg7pz7NIaQMjkXGkQpPD99U1VfXSGIjjlPf4eKTmxclCDVotcsDxWtV
SeD2z1X+xAoEtH87XLrjlg9oTT74Dz76rOu+H6O+5kGuVlX3teMNuEeA1qHL9idS
qnV30Q8Lrw/jm1u2WJn1adVaDyuhQElYthHVYMQSvgdelHTMLGhVMg0JuuU9TRFj
7A1DnSitogymC6iSUfl8mJ+P4Q6wqRDKiz+GZH3UBMoSlekkJpInqkaTFgw3Ves8
+7rK92ywGeDQAKUzq2AMBA3nqZ8eWtp9kV+OaYbnQzWbOyOj/WxbQr+BLfDAcq2v
Z1ChJ3us6a2IKNF04FiQ8UmmT6E09DZGcMP5f13anMbPoJ3OVXr/SzSDhl/5Vy7W
JLq/nH67fIX1RVr+s4Wu5o30J3zLaaOaXEJuQjZQNpToUw6oKIb7eghhmQARAQAB
tC9EaWxsZW5uIFRlcnVtYWxhaSA8ZGlsbGVubi50ZXJ1bWFsYWlAc2liLnN3aXNz
PokCVAQTAQgAPhYhBO50rHT5D+yitFrf4q2yPHjqJRjnBQJdMc3gAhsjBQkJZgGA
BQsJCAcCBhUKCQgLAgQWAgMBAh4BAheAAAoJEK2yPHjqJRjnbisP/iM4wYHXLYeL
64hSyL35ltazQEnLQWf3PPyFFLnnZpsp5MoaP5V4TRzzlO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JWZJ3dRheVkI0Bd1Y7EuFWGXqVLT
5teU4bCeKbBBlBCWyhYomOpvErovufXLFZyXWdfPEbEpiz0v3f1LlDO22cSaYd3y
FFQP8sPfwtS40NabeOoIVMTRiL9OG/JGkCA1l8Q1+HLG/sGaPqFSjB6W4Tt6qcDn
ABEBAAGJATYEGAEIACAWIQSryfwUqslS53Z/0UpItw5yS6/gowUCXfeqGgIbDAAK
CRBItw5yS6/go1adB/4+EpKqokTNw8bOPAdOP1SnumtFMBXihGqpfpcjWG48vgHK
00CB3ocUxLheo7j/35SzUnfK9RV1+yKi8QWs/4REBWAyxyc47AaoHiEofn/muwXG
m48O5ivHMO3I7xjwptDxBr7awfTAAHIE7Zf84dkadHm6mw0Ik+2fX+/0bXpZYxgH
aREL2CblAWr23DLrcr0qgtxB07mi/HCvy7AFUFFhJl+Xgeb4xOcEPnI49RcwRoMh
5nhvWFChKezomuu8JXCGBjh1r4+RhFjkDj67O9hNmbi1KsQ7wAJJdgpkcqyC+OiL
JIj37JtjJsDKkzDyPZjqDZAiKCfy6gbt+8CPtCZd
=8nX5
-----END PGP PUBLIC KEY BLOCK-----
......@@ -22,8 +22,31 @@ If you want to be able to use the tool smoothly, make sure that you have:
- OS: macOS or Linux - This script can only run on those operative systems
- SSH: public key uploaded - This script is assuming that you have generated and transferred your public SSH key to the SPSP SFTP Server. If not, please read the [Installation](#installation) chapter
- GPG: gpg avaiable - This script uses GPG to encrypt the data, make sure that you can run this command (`which gpg`)
- (Optional)CRON: automatic mode - If you want to activate the automatic mode of the transfer-tool make sure that you can setup a CRON task
- (Optional) CRON: automatic mode - If you want to activate the automatic mode of the transfer-tool make sure that you can setup a CRON task
## Upload the SSH public key
Before using the script, you need to make sure that you create an SSH key pair for user authentication.
Start by generating a key pair, make sure to replace `user` by your specific ID provided by the board of SPSP. Open a terminal and type:
```bash
ssh-keygen -t rsa -b 4096 -C user@spsp.sib.swiss #PLEASE REPLACE USER WITH YOUR OWN ID
```
You will be asked to `Enter file in which to save the key (/Users/user/.ssh/id_rsa):`, leave it by default by typing the return key.
Then you will be asked to `Enter passphrase (empty for no passphrase):`, leave it empty and type two times the return key to confirm your choice.
You will then be prompted that your SSH public key has been saved to `/Users/user/.ssh/id_rsa.pub`. This is your public key that needs to be authorized on the SPSP SFTP Server.
For the next step, you will need to upload your key. Start by copying your key. Type the following to display the public key:
```bash
cat /Users/user/.ssh/id_rsa.pub #PLEASE REPLACE user WITH YOUR LOCAL ACCOUNT
```
Then click [here](spsp.sib.swiss/upload-key) to send your key. Once the key has been validated, you will notified by mail.
## Installation
......
......@@ -47,7 +47,7 @@ elif [ "$MACHINE" == "mac" ]; then
fi
showVersion() {
intro="\n🔐${COL_GREEN} SPSP transfer-tool${COL_RESET}\n"
intro="\n🔐${COL_GREEN} SPSP transfer-tool${COL_RESET}\n"
intro="$intro ${COL_CYAN}Version ${VERSION}\n${COL_RESET}"
printf "$intro"
......@@ -61,12 +61,11 @@ showHelp() {
usage="$usage ./spsp <cmd> <options>"
commands="${COL_LYELLOW}Commands:\n${COL_RESET}"
commands="$commands compress <folder> Compress the ${COL_LGREEN}FASTQ${COL_RESET} files to ${COL_LYELLOW}tar.gz${COL_RESET} file\n"
commands="$commands compress <folder> Compress the ${COL_LGREEN}FASTQ${COL_RESET} and ${COL_LGREEN}XSLX${COL_RESET} files to ${COL_LYELLOW}tar.gz${COL_RESET} file\n"
commands="$commands encrypt <compressed file> Encrypt a ${COL_LGREEN}tar.gz${COL_RESET} file using a public key\n"
commands="$commands transfer <encrypted file> Transfer the encrypted file using ${COL_LGREEN}sftp${COL_RESET}\n"
commands="$commands auto Automatically run the commands in a correct order to ${COL_CYAN}compress${COL_RESET}, ${COL_GREEN}encrypt${COL_RESET} & ${COL_MAGENTA}transfer${COL_RESET}\n"
commands="$commands transfer <encrypted file> Transfer the encrypted file using ${COL_LGREEN}SFTP${COL_RESET}\n"
commands="$commands auto Automatically run the commands to ${COL_CYAN}Compress${COL_RESET}, ${COL_GREEN}Encrypt${COL_RESET} & ${COL_MAGENTA}Transfer${COL_RESET}\n"
commands="$commands help Shows Help screen\n"
commands="$commands logs Displays the content of the main log \n"
options="${COL_LYELLOW}Options:\n${COL_RESET}"
options="$options --help, -h Shows Help (this screen)\n"
......@@ -77,7 +76,6 @@ showHelp() {
examples="$examples ${COL_CYAN}$ ./script encrypt myfile.tar.gz${COL_RESET}\n"
examples="$examples ${COL_CYAN}$ ./script transfer myencryptedfile${COL_RESET}\n"
examples="$examples ${COL_CYAN}$ ./script auto${COL_RESET}\n"
examples="$examples ${COL_CYAN}$ ./script logs${COL_RESET}\n"
printf "\n"
printf "$usage\n\n"
......@@ -192,22 +190,22 @@ if [ $# -gt 0 ]; then
OUTBOX=outbox
if [ ! -d "$OUTBOX" ]; then
echo "No $OUTBOX folder found within current working directory ${pwd}"
echo "Creating the $OUTBOX folder..."
echo "SPSP: No $OUTBOX folder found within current working directory ${pwd}"
echo "SPSP: Creating the $OUTBOX folder..."
mkdir $OUTBOX
fi
SENT=sent
if [ ! -d "$SENT" ]; then
echo "No $SENT folder found within current working directory ${pwd}"
echo "Creating the $SENT folder..."
echo "SPSP: No $SENT folder found within current working directory ${pwd}"
echo "SPSP: Creating the $SENT folder..."
mkdir $SENT
fi
LOGS=logs
if [ ! -d "$LOGS" ]; then
echo "No $LOGS folder found within current working directory ${pwd}"
echo "Creating the $LOGS folder..."
echo "SPSP: No $LOGS folder found within current working directory ${pwd}"
echo "SPSP: Creating the $LOGS folder..."
mkdir $LOGS
fi
......@@ -215,11 +213,16 @@ if [ $# -gt 0 ]; then
if [ ! -f $LOGFILE ]; then
touch $LOGFILE
fi
echo "================================="
for DIRECTORY in *; do
if [ -d "$DIRECTORY" ] && [ $DIRECTORY != $OUTBOX ] && [ $DIRECTORY != $SENT ] && [ $DIRECTORY != $LOGS ]; then
if [ -f $DIRECTORY/*.fastq ] && [ -f $DIRECTORY/*.xlsx ]; then
echo $DIRECTORY
if [ -f $DIRECTORY/*.fastq* ] && [ -f $DIRECTORY/*.xlsx ]; then
echo "SPSP: Compressing $DIRECTORY folder..."
compressFolder $DIRECTORY &> /dev/null
echo "SPSP: Sucessfully compressed!"
echo "SPSP: Removing the source and moving the tar.gz to output folder."
# rm -rf $DIRECTORY
mv $DIRECTORY.tar.gz ./outbox/.
else
echo "[`date +"%T"`] local.ERROR: Missing files (*.fastq or *.xlsx) inside ${DIRECTORY}" >> $LOGFILE
echo "SPSP: Error detected please check $LOGFILE"
......@@ -227,9 +230,39 @@ if [ $# -gt 0 ]; then
fi
fi
done
echo ""
echo "SPSP: Transfer completed!"
echo "================================="
for FILE in ./outbox/*; do
if [ -f "$FILE" ]; then
echo "SPSP: Signing $FILE using SHA-256 algorithm..."
signFile $FILE &> /dev/null
echo "SPSP: $File is now signed!"
echo "SPSP: Encrypting $FILE using SPSP public key..."
encryptFile $FILE &> /dev/null
echo "SPSP: $FILE is now encrypted"
echo "SPSP: Removing unencrypted version of $FILE"
# rm -rf $FILE
echo "SPSP: Deleted!"
if [ -f "$FILE.sha256" ] && [ -f "$FILE.gpg" ]; then
echo "SPSP: Starting the transfer"
transferFile $FILE.sha256 &> /dev/null
transferFile $FILE.gpg &> /dev/null
echo "SPSP: $FILE has been transferred sucessfully!"
mv $FILE.sha256 ./sent/.
mv $FILE.gpg ./sent/.
else
echo "[`date +"%T"`] local.ERROR: Missing the encrypted version or the signature for $FILE" >> $LOGFILE
echo "SPSP: Error detected please check $LOGFILE"
exit 0
fi
echo ""
else
echo "[`date +"%T"`] local.ERROR: No file found inside output directory" >> $LOGFILE
echo "SPSP: Error detected please check $LOGFILE"
exit 0
fi
done
echo "================================="
echo "SPSP: Process completed!"
# Compress a folder given as an input
elif [ "$1" == "compress" ]; then
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment