Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
A volte nei sistemi Unix/Linux si fa uso di account machine to machine in SFTP per
ricevere file che possono contenere dati sensibili; Tali file ottenuti tramite un flusso
batch dovranno essere rielaborati ulteriormente da un ETL, da un Dispatcher o da un
sistema ESB per ricavare informazioni da inserire in un database o produrre un flusso
on-line in una architettura SOA.
In termini di sicurezza occorre fare attenzione al duplice problema del transito dei
dati con protocolli sicuri (SFTP, SSH, etc) e della permanenza dei file sul file system
stesso per un certo periodo.
Nel panorama file system crittato con buoni algoritmi di cifratura appare CFS, un
prodotto Open Source.
o pochissime vulnerabilità
Nel seguito si suppone di usare una versione cfs-1.4.1,tar ma voi userete l’ultima
versioni disponibile sul sito.
In produzione non si può fare compilazione, né conviene portare sul versionatore del
software (SVN, PVCS, CVS o altro) i sorgenti e il Makefile per una questione di
sicurezza. Per cui si creerà solo un tar degli eseguibili.
Da root
portare nella $home il tar CFS-TAR.tar (che conserva anche i privilegi).
Lo script provvede a distribuire i file sul nodo del root. Lo script deve essere lanciato
Per ogni nodo del cluster da root.
Note
1) è il file secrets che cresce di dimensioni.
2) Lo script si attende un filesystem gfs denominato da root /null e con protezioni
chmod 0 /null.
Lo script provvede a:
aggiungere in /etc/exports:
/null localhost
aggiungere in /etc/dfs/dfstab
share -F nfs -o rw=localhost -d "cfs directory" /null
eseguire il comando:
shareall
3) Prima di un UPGRADE del prodotto CFS (cambio versione CFS) si richiede che
da root, su ogni nodo del cluster, si effettuano i seguenti comandi:
umount /crypt
ps -efa | grep cfsd
nohup /etc/rc3.d/S99cfs-rclocal
Prerequisiti
L’installazione presume:
- l’esistenza di un gfs (global-file-system) con mount point /ftp_input.
- La possibilità di usare NFS in localhost
Utilizzo CFS
Da utente applicativo unix per operare con il filesystem criptato occorre fare
l’attach con i due comandi:
sh /usr/local/bin/myattach.sh <alias_utente> <passphrase>
cd /crypt
ls
Start CFS
Da root, su ogni nodo del cluster (DB cluster), effettuare il seguente comando:
nohup /etc/rc3.d/S99cfs-rclocal
Cambio password
Da root, su un qualsiasi nodo del cluster, effettuare il seguente comando:
/usr/local/bin/cpasswd /ftp_input/secrets
Old passphrase:
New passphrase:
Again:
Attach
E’ possibile fare un attach nel seguente modo:
Detach
E’ possibile fare il detach nel seguente modo:
APPENDICE
Shell startPaTH.sh
Shell install-cfs.sh
Installa il prodotto in un mount-point /ftp_input/secrets
#!/bin/sh
# Configurazione CFS
clear
if [ -d /usr/local/etc ]
then
echo " "
echo "OK: /usr/local/etc esistente"
echo " "
else
mkdir /usr/local/etc
fi
cp -f cattach /usr/local/bin/.
cp -f cdetach /usr/local/bin/.
cp -f cfssh /usr/local/bin/.
cp -f cmkkey /usr/local/bin/.
cp -f cpasswd /usr/local/bin/.
cp -f ccat /usr/local/bin/.
cp -f cmkdir /usr/local/bin/.
cp -f cname /usr/local/bin/.
cp -f myattach.sh /usr/local/bin/.
cp -f secureattach.sh /usr/local/bin/.
cp -f mydetach.sh /usr/local/bin/.
cp -f cfsd /usr/local/etc/.
if [ -f /etc/dfs/dfstab ]
then
echo "##" >> /etc/dfs/dfstab
echo "## Non toccare: sono per CFS (Cryptographic Filesystem)" >>
/etc/dfs/dfstab
echo "##" >> /etc/dfs/dfstab
echo "share -F nfs -o rw=localhost -d \"cfs filesystem\" /null" >> /etc/dfs/dfstab
else
echo "##" > /etc/dfs/dfstab
echo "## Non toccare: sono per CFS (Cryptographic Filesystem)" >>
/etc/dfs/dfstab
echo "##" >> /etc/dfs/dfstab
echo "share -F nfs -o rw=localhost -d \"cfs filesystem\" /null" >> /etc/dfs/dfstab
fi
mkdir /crypt
mkdir /null
chmod 0 /null
if [ -d /ftp_input/secrets ]
then
echo " "
echo "Passprhase è in /ftp_input/secrets"
echo " "
else
echo "-Prima Area- "
echo "Creazione Passprhase in /ftp_input/secrets (almeno 16 caratteri)"
/usr/local/bin/cmkdir /ftp_input/secrets
echo " "
echo "Conservare la prima password "
echo " "
fi
if [ -d /ftp_input/mysecure ]
then
echo "-Seconda Area- "
echo "Passprhase è in /ftp_input/mysecure"
echo " "
else
echo " "
echo "Inserisci la password iniziale di seguito indicata: xyz20m06busbu0rcs0"
/usr/local/bin/cmkdir /ftp_input/mysecure
echo " "
fi
Shell makeDBcryptfs.sh
Serve a creare 3 directory (di esempio nell’articolo) e di appoggio sul file system
crittato a cui accedere successivamente da operatore, quando egli sposterà
manualmente i file oppure anche da applicativo.
#!/bin/sh
if [ $# = 0 ]
then
echo "Errore: Inserire anche la passphrase operatore!!"
exit 0
fi
sh /usr/local/bin/myattach.sh creafsdb $1
var=0
while [ $var -lt 1 ]
do
echo ".........."
if [ -d /crypt/creafsdb ]
then
var=2
echo "Attach eseguito"
sleep 5
fi
done
echo "posizionamento su /crypt"
cd /crypt/creafsdb
mkdir -p migrazione
mkdir -p dbspecchio
mkdir -p recovery
echo "Creazione directory eseguita"
sh /usr/local/bin/mydetach.sh creafsdb
shell S99cfs-rclocal
#!/sbin/sh
#
# Configurazione per CFS
#
if [ -x /usr/local/etc/cfsd ]; then
/usr/local/etc/cfsd && \
/etc/mount -o port=3049,vers=2,proto=udp,intr localhost:/null /crypt
Fi
Shell myattach.sh
#!/bin/sh
#
# $1 alias di attach a CFS
# $2 password di attach a CFS
#
#
#
# Controlla se l'alias è già attaccato
# Se e' gia' attaccato l'alias viene restituito 1 con exit
#
#
if [ $# = 0 ]
then
echo "Usage: myattach.sh <alias> <passphrase>"
exit 1
fi
if [ $# != 2 ]
then
echo "Usage: myattach.sh <alias> <passphrase>"
exit 1
fi
if [ -d /crypt/$1 ]
then
exit 0
fi
#
# L'attach ha un timeout di 30 minuti
#
Shell mydetach.sh
#!/bin/sh
#
# $1 alias di attach a CFS
#
if [ $# = 0 ]
then
echo "Usage: mydetach.sh <alias>"
exit 0
fi
/usr/local/bin/cdetach $1 << EOF
exit $?
Shell secureattach.sh
#!/bin/sh
#
# $1 alias di attach a CFS
# $2 password di attach a CFS
#
#
#
# Controlla se l'alias è già attaccato
# Se e' gia' attaccato l'alias viene restituito 1 con exit
#
#
if [ $# = 0 ]
then
echo "Usage: secureattach.sh <alias> <passphrase>"
exit 1
fi
if [ $# != 2 ]
then
echo "Usage: secureattach.sh <alias> <passphrase>"
exit 1
fi
if [ -d /crypt/$1 ]
then
exit 0
fi
#
# L'attach ha un timeout di 30 minuti
#