Translation(s): English - Italiano
Cifratura trasparente della directory Home dell'utente
I passi descritti in seguito sono stati completati su una nuova installazione di Debian Squeeze per permettere agli utenti di un ambiente desktop di cifrare la propria directory Home.
Contents
- Cifratura trasparente della directory Home dell'utente
- Transparent Encryption For a User's Home Folder
- Transparent Encryption For a User's Home Folder
- Transparent Encryption For a User's Home Folder
- Transparent Encryption For a User's Home Folder
- Transparent Encryption For a User's Home Folder
- Transparent Encryption For a User's Home Folder
Introduzione
Molte organizzazioni richiedono ai propri utenti di cifrare i loro portatili per proteggere le informazioni confidenziali (nomi dei clienti, dettagli dei contatti interni, ecc.). Su molti sistemi Windows ciò è problematico e invasivo. Questa pagina è pensata per aiutare gli utenti Debian nella configurazione dei propri sistemi in modo da cifrare e decifrare auto-magicamente la loro directory Home usando EncFS.
Installare Debian Squeeze
I passi descritti in questa pagina sono basati su un "Debian Live CD con desktop Gome", but qualsiasi supporto di installazione dovrebbe andare bene. Per ulteriori dettagli sull'installazione di Debian, vedere il sito web di Debian.
Account utente fittizio
Quando viene impostato il primo utente (durante la procedura di installazione), è consigliato creare un account fittizio (ad esempio "Utente Fittizio"). Ciò permetterà di fare una configurazione completa per l'utente "vero".
Configurazione del disco
Nelle impostazioni del disco, scegliere "Guidata - usa l'intero disco" o "Guidata - usa l'intero disco e imposta LVM". La cifratura NON verrà configurata usando il metodo dell'installatore Debian.
La scelta raccomandata è quella di selezionare "Tutti i file in una partizione" e accettare i valori predefiniti.
Quando l'installazione è completata, fare il login con l'utente fittizio creato durante l'installazione. Questo utente sarà in grado di ottenere i privilegi di root necessari per il resto della procedura.
Dopo aver installato Debian, assicurarsi sempre che il sistema sia aggiornato, perciò eseguire i seguenti comandi:
aptitude update ; aptitude safe-upgrade
Impostare le directory Home cifrate
Spostare l'utente fittizio in una directory che non è gestita da encfs (cioè non sotto /home /home)
mkdir -p /home.originale/ cp -a /home/<dummy-username> /home.originale/
Modificare /etc/passwd in modo che il percorso della directory home dell'utente fittizio sia impostato correttamente (es. /home.originale/<dummy-username>).
Quindi fare il log out e nuovamente il login. Rimuovere la vecchia directory home dell'utente fittizio:
rm -rf /home/<dummy-username>
In un sistema Debian aggiornato, installare i pacchetti encfs, libpam-encfs e libpam-mount:
aptitude install encfs libpam-encfs libpam-mount
Modificare i file di configurazione
L'autore originale di questa pagina ha copiato il contenuto dei propri file di configurazione dato che l'ordine delle varie voci nei file è importatne e, quando ha impostato la cosa per sé stesso, la documentazione a cui faceva riferimento aveva solo le aggiunte.
/etc/security/pam_encfs.conf
Include: Nothing found for "^##TAG:PAM_ENCFS_START"!
Include: Nothing found for "^##TAG:PAM_ENCFS_END"!
Translation(s): English - Italiano
Transparent Encryption For a User's Home Folder
Check out a new alternative
Before you proceed, please check out gocryptfs. It is comparable to encfs, but offers better encryption at similar speeds. (It also works great over NFSv4.) You can use regular libpam-mount to make your home folder available at login.
Contents
Requirements
First install the packages ecryptfs-utils and rsync:
sudo apt-get install ecryptfs-utils rsync lsof
Then load the ecryptfs kernel module:
sudo modprobe ecryptfs
And make it permanent in /etc/modules-load.d/modules.conf.
Assisted Encrypted Home Directory
The user whose home directory you want to encrypt MUST NOT be logged in. For example, you can be logged as root in a tty.
Then run as root:
ecryptfs-migrate-home -u <username>
When this is done the user must login BEFORE rebooting the computer.
If the user can access the files in the users home directory you can remove the backup folder in /home/<username>.<random characters>
The user should also run this command to get the random encryption key and store it in a secure location (outside the encrypted home directory and not on the same machine) in case a recovery is needed:
ecryptfs-unwrap-passphrase
Assisted Encrypted Swap Partition
To encrypt the swap partition too:
sudo apt-get install cryptsetup sudo ecryptfs-setup-swap
/etc/security/pam_env.conf
Questa modifica è necessaria per rimuovere il noioso messaggio "Cannot update ICEauthority /home/(user)/.ICEauthority. La modifica è contenuta nell'ultima riga di questo esempio.
Include: Nothing found for "^##TAG:PAM_ENV_START"!
Include: Nothing found for "^##TAG:PAM_ENV_END"!
Translation(s): English - Italiano
Transparent Encryption For a User's Home Folder
Check out a new alternative
Before you proceed, please check out gocryptfs. It is comparable to encfs, but offers better encryption at similar speeds. (It also works great over NFSv4.) You can use regular libpam-mount to make your home folder available at login.
Contents
Requirements
First install the packages ecryptfs-utils and rsync:
sudo apt-get install ecryptfs-utils rsync lsof
Then load the ecryptfs kernel module:
sudo modprobe ecryptfs
And make it permanent in /etc/modules-load.d/modules.conf.
Assisted Encrypted Home Directory
The user whose home directory you want to encrypt MUST NOT be logged in. For example, you can be logged as root in a tty.
Then run as root:
ecryptfs-migrate-home -u <username>
When this is done the user must login BEFORE rebooting the computer.
If the user can access the files in the users home directory you can remove the backup folder in /home/<username>.<random characters>
The user should also run this command to get the random encryption key and store it in a secure location (outside the encrypted home directory and not on the same machine) in case a recovery is needed:
ecryptfs-unwrap-passphrase
Assisted Encrypted Swap Partition
To encrypt the swap partition too:
sudo apt-get install cryptsetup sudo ecryptfs-setup-swap
/etc/fuse.conf
Include: Nothing found for "^##TAG:FUSE_START"!
Include: Nothing found for "^##TAG:FUSE_END"!
Translation(s): English - Italiano
Transparent Encryption For a User's Home Folder
Check out a new alternative
Before you proceed, please check out gocryptfs. It is comparable to encfs, but offers better encryption at similar speeds. (It also works great over NFSv4.) You can use regular libpam-mount to make your home folder available at login.
Contents
Requirements
First install the packages ecryptfs-utils and rsync:
sudo apt-get install ecryptfs-utils rsync lsof
Then load the ecryptfs kernel module:
sudo modprobe ecryptfs
And make it permanent in /etc/modules-load.d/modules.conf.
Assisted Encrypted Home Directory
The user whose home directory you want to encrypt MUST NOT be logged in. For example, you can be logged as root in a tty.
Then run as root:
ecryptfs-migrate-home -u <username>
When this is done the user must login BEFORE rebooting the computer.
If the user can access the files in the users home directory you can remove the backup folder in /home/<username>.<random characters>
The user should also run this command to get the random encryption key and store it in a secure location (outside the encrypted home directory and not on the same machine) in case a recovery is needed:
ecryptfs-unwrap-passphrase
Assisted Encrypted Swap Partition
To encrypt the swap partition too:
sudo apt-get install cryptsetup sudo ecryptfs-setup-swap
/etc/pam.d/common-session
Include: Nothing found for "^##TAG:PAM_COMMONSESSION_START"!
Include: Nothing found for "^##TAG:PAM_COMMONSESSION_END"!
Translation(s): English - Italiano
Transparent Encryption For a User's Home Folder
Check out a new alternative
Before you proceed, please check out gocryptfs. It is comparable to encfs, but offers better encryption at similar speeds. (It also works great over NFSv4.) You can use regular libpam-mount to make your home folder available at login.
Contents
Requirements
First install the packages ecryptfs-utils and rsync:
sudo apt-get install ecryptfs-utils rsync lsof
Then load the ecryptfs kernel module:
sudo modprobe ecryptfs
And make it permanent in /etc/modules-load.d/modules.conf.
Assisted Encrypted Home Directory
The user whose home directory you want to encrypt MUST NOT be logged in. For example, you can be logged as root in a tty.
Then run as root:
ecryptfs-migrate-home -u <username>
When this is done the user must login BEFORE rebooting the computer.
If the user can access the files in the users home directory you can remove the backup folder in /home/<username>.<random characters>
The user should also run this command to get the random encryption key and store it in a secure location (outside the encrypted home directory and not on the same machine) in case a recovery is needed:
ecryptfs-unwrap-passphrase
Assisted Encrypted Swap Partition
To encrypt the swap partition too:
sudo apt-get install cryptsetup sudo ecryptfs-setup-swap
/etc/pam.d/common-auth
Include: Nothing found for "^##TAG:PAM_COMMONAUTH_START"!
Include: Nothing found for "^##TAG:PAM_COMMONAUTH_END"!
Translation(s): English - Italiano
Transparent Encryption For a User's Home Folder
Check out a new alternative
Before you proceed, please check out gocryptfs. It is comparable to encfs, but offers better encryption at similar speeds. (It also works great over NFSv4.) You can use regular libpam-mount to make your home folder available at login.
Contents
Requirements
First install the packages ecryptfs-utils and rsync:
sudo apt-get install ecryptfs-utils rsync lsof
Then load the ecryptfs kernel module:
sudo modprobe ecryptfs
And make it permanent in /etc/modules-load.d/modules.conf.
Assisted Encrypted Home Directory
The user whose home directory you want to encrypt MUST NOT be logged in. For example, you can be logged as root in a tty.
Then run as root:
ecryptfs-migrate-home -u <username>
When this is done the user must login BEFORE rebooting the computer.
If the user can access the files in the users home directory you can remove the backup folder in /home/<username>.<random characters>
The user should also run this command to get the random encryption key and store it in a secure location (outside the encrypted home directory and not on the same machine) in case a recovery is needed:
ecryptfs-unwrap-passphrase
Assisted Encrypted Swap Partition
To encrypt the swap partition too:
sudo apt-get install cryptsetup sudo ecryptfs-setup-swap
Creare la directory Home cifrata
La configurazione imposterà encfs per un nuovo utente "reale".
Creare l'utente "reale" e assicurarsi che venga aggiunto al gruppo fuse.
adduser <nomeutente> usermod -aG fuse <nomeutente>
Spostare la sua directory home con i file in un'altra posizione:
mkdir /var/backups/<nomeutente_home> mv /home/<nomeutente>/.* /var/backups/<nomeutente_home>/. rmdir /home/<nomeutente> mkdir -p /home/.encfs/<nomeutente> /home/<nomeutente> chown <nomeutente>.<nomeutente> /home/.encfs/<nomeutente> /home/<nomeutente>
Creare la directory cifrata (se si incontrano problemi con i permessi, vedere la Sezione sui permessi):
encfs -v /home/.encfs/<nomeutente> /home/<nomeutente>
Accettare le opzioni predefinite oppure modificare le impostazioni per la cifratura. La modalità "paranoia" funziona, ma non gestisce i collegamenti fisici. L'autore ha usato la modalità paranoia con successo.
IMPOSTARE LA PASSWORD IN MODO CHE SIA IDENTICA A QUELLA DI LOGIN
Controllare che il file system cifrato sia montato correttamente:
mount
Questo comando dovrebbe produrre un output simile al seguente:
encfs on /home/<nomeutente> type fuse.encfs (rw,nosuid,nodev,default_permissions)
Riportare la directory home con i suoi file nella posizione originale:
mv /var/backups/<nomeutente_home>/* /home/<nomeutente>/.
Riavviare
Sarà necessario riavviare per ricaricare tutte le librerie PAM, ecc.
Ora si può testare se tutto funziona a dovere con l'utente "reale". Se si incontrano problemi, si può fare il login come l'utente fittizio per risolverli. Se tutto funziona come deve, basta commentare l'utente fittizio dal file password e il file shadow password.
Per verificare che le scritture nella directory home siano cifrate, creare un file qualsiasi nella propria directory home e vedere se esiste un file corrispondente nella directory home cifrata. Guardare l'orario del file e controllare file o directory create nella directory home cifrata (ad esempio /home/.encfs/<nomeutente>).
cp /etc/passwd $HOME/. ls -l /home/<nomeutente>/passwd ls -ltra /home/.encfs/<nomeutente>
Possibili problemi
Se le cose vanno storto a questo punto, ci si può trovare bloccati con un sistema in cui non si può fare il login. È necessario testarlo prima di fare qualsiasi altra cosa. Come prima cosa controllare di poter eseguire encfs /home/.encfs/<nomeutente> /home/<nomeutente> come utente normale (senza usare sudo), così come /bin/fusermount -u /home/<nomeutente>. Se ciò ha successo, usare Ctrl-Alt-F2 per spostarsi in un altro terminale virtuale e controllare se si può vare il login senza problemi (assicurarsi di essere nella directory home cifrata!). Usare Ctrl-Alt-F7 per ritornare a Gnome e testare da lì.
Se si è particolarmente paranoici, considerare l'ipotesi di aggiungere un altro utente e di fare prima un test con tale utente (sarà necessario aggiungerlo manualmente ai gruppi admin e fuse).
Bene, ora, se si è sicuri che tutto funziona, si può riavviare. Se si riesce, fare il login e cancellare la propria directory <nomeutente>.original.
Permessi
Se si hanno dei problemi con i permessi, si può controllare quanto segue:
- Si può leggere /etc/fuse.conf senza sudo? Se non è così, eseguire "sudo chgrp fuse /etc/fuse.conf"
Si può eseguire fusermount (o /bin/fusermount) da utente normale? Si dovrebbe testare questo prima di fare il log out, eseguendo encfs per montare la propria directory home cifrata manualmente. Se non è così, eseguire sudo chgrp fuse /bin/fusermount e sudo chmod 4750 /bin/fusermount
Riferimento: http://wiki.geteasypeasy.com/Transparent_Encryption_for_home_folder
Cambiare la password dell'utente
La password del file system cifrato e la password dell'utente sono sincronizzate. Perciò, per cambiare la password dell'utente è necessario cambiare la sua password personale con il comando passwd:
passwd
e modificare la password del volume cifrato in modo corrispondente:
encfsctl passwd /home/.encfs/<nomeutente>
Utilità per la password
Ci sono alcune problematiche importanti nell'automatizzare questo processo e l'utente deve essere in grado di cambiare la propria password. Ciò richiede l'uso dell'utilità passwd (dato che è l'unico binario suid). Tuttavia, è possibile superare questi ostacoli con l'uso di uno script expect. Perciò installare il pacchetto expect:
aptitude install expect
Poi copiare il codice seguente in /usr/local/bin/passwd. Il PATH di un normale utente Debian è impostato per eseguire questa utilità passwd prima di quella di sistema in /usr/bin.
Include: Nothing found for "^##TAG:PASSWD_UTILITY_START"!
Include: Nothing found for "^##TAG:PASSWD_UTILITY_END"!
Translation(s): English - Italiano
Transparent Encryption For a User's Home Folder
Check out a new alternative
Before you proceed, please check out gocryptfs. It is comparable to encfs, but offers better encryption at similar speeds. (It also works great over NFSv4.) You can use regular libpam-mount to make your home folder available at login.
Contents
Requirements
First install the packages ecryptfs-utils and rsync:
sudo apt-get install ecryptfs-utils rsync lsof
Then load the ecryptfs kernel module:
sudo modprobe ecryptfs
And make it permanent in /etc/modules-load.d/modules.conf.
Assisted Encrypted Home Directory
The user whose home directory you want to encrypt MUST NOT be logged in. For example, you can be logged as root in a tty.
Then run as root:
ecryptfs-migrate-home -u <username>
When this is done the user must login BEFORE rebooting the computer.
If the user can access the files in the users home directory you can remove the backup folder in /home/<username>.<random characters>
The user should also run this command to get the random encryption key and store it in a secure location (outside the encrypted home directory and not on the same machine) in case a recovery is needed:
ecryptfs-unwrap-passphrase
Assisted Encrypted Swap Partition
To encrypt the swap partition too:
sudo apt-get install cryptsetup sudo ecryptfs-setup-swap
1 #!/usr/bin/expect -f
2 #
3 # What: /usr/local/bin/passwd
4 # When: 6/Mar/2012
5 # Who: Philip Jensen (partially generated by autoexpect - refer expect-dev)
6 # Why: To keep a user's password in sync with their encfs password
7 # which needs to be unlocked when the user logs in.
8
9 set force_conservative 0 ;# set to 1 to force conservative mode even if
10 ;# script wasn't run conservatively originally
11 if {$force_conservative} {
12 set send_slow {1 .1}
13 proc send {ignore arg} {
14 sleep .1
15 exp_send -s -- $arg
16 }
17 }
18
19 # Tell the user they aren't using the real passwd utility.
20 puts "###############################################################"
21 puts "# #"
22 puts "# This 'passwd' utility overrides the original. #"
23 puts "# #"
24 puts "# It is used to change the user's UNIX password #"
25 puts "# as well as their encrypted file system password. #"
26 puts "# #"
27 puts "# The original password changing utility is /usr/bin/passwd #"
28 puts "# #"
29 puts "###############################################################"
30
31 # Who is the user we are changing the password for.
32 # (actually this is needed for encfsctl - see below)
33 set user [exec whoami]
34 puts "\nChanging password for $user. If this is incorrect press Ctrl + C\r"
35
36 # Get the user's current password.
37 send_user "\nCurrent password: "
38 stty -echo
39 expect_user -re "(.*)\n"
40 set curr_password $expect_out(1,string)
41 stty echo
42
43 # Get their new password
44 send_user "\nNew password: "
45 stty -echo
46 expect_user -re "(.*)\n"
47 set new_password_one $expect_out(1,string)
48 stty echo
49 send_user "\nRe-enter new password: "
50 stty -echo
51 expect_user -re "(.*)\n"
52 set new_password_two $expect_out(1,string)
53 stty echo
54 puts "\n"
55
56 # Do the *NEW* passwords match?
57 if {$new_password_one!=$new_password_two} {
58 puts "Passwords don't match, exiting!\n"
59 exit 2
60 } else {
61 set new_password "$new_password_one"
62 }
63
64 # Debug output
65 #puts "Changing password from: $curr_password\nto: $new_password\n"
66
67 # Hide output from the screen (operate in silent mode).
68 # Of course this may not hide any potential output from the command line.
69 # Beware of background process watchers.
70 log_user 0
71
72 set timeout -1
73 spawn /bin/sh
74 match_max 100000
75
76 # begin changing passwords
77 puts "\nChanging user's password."
78
79 send -- "/usr/bin/passwd\r"
80 expect -exact "/usr/bin/passwd\r
81 Changing password for $user.\r
82 (current) UNIX password: "
83 send -- "$curr_password\r"
84 # we need to handle the user entering an incorrect current password.
85 expect {
86 "Authentication token manipulation error" {puts "Current User password incorrect!" ; exit }
87 "Enter new UNIX password: " { send -- "$new_password\r" }
88 }
89
90 expect -exact "Retype new UNIX password: " { send -- "$new_password\r" }
91 expect -exact "\r
92 passwd: password updated successfully\r"
93 send_user "User password changed successfully."
94
95 # If we get this far, changing the user's password succeeded,
96 # therefore we can proceed to change the encfs password.
97 puts "\nChanging encfs password."
98 expect -exact "\$ "
99 send -- "/usr/bin/encfsctl passwd /home/.encfs/$user\r"
100 expect -exact "\r
101 Enter current Encfs password\r
102 EncFS Password: "
103 send -- "$curr_password\r"
104
105 # what if the current encfs password didn't match the current user's password
106 # Of course now we have a very BIG problem as the transparent login won't work.
107 # But if they've used this utility, then they should be fine. ;-)
108 expect {
109 "Invalid password\r" { puts "Current encfs password incorrect!" ; exit }
110 "New Encfs Password: " { send -- "$new_password\r" }
111 }
112 expect -exact "\r
113 Verify Encfs Password: "
114 send -- "$new_password\r"
115 expect -exact "\r
116 Volume Key successfully updated.\r
117 \$ "
118 puts "Password change complete!"
119 send -- "exit\r"
120 expect eof