Tentei isso no XFCE, mas não tenho certeza se o Unity / Gnome / KDE / etc são todos iguais para arquivos de inicialização de execução no login, então YMMV.
Um arquivo .desktop em ~ / .config / autostart será executado no login, dizendo para executar um script bash que monta sua pasta criptografada deve funcionar. Como sua casa já está criptografada, você pode armazenar a outra senha de montagem no script bash, não uma segurança perfeita, mas ainda criptografada no disco, se você não quiser inseri-la a cada vez. Por exemplo, ~/.config/autostart/test.desktop
. Um muito básico como este deve funcionar:
[Desktop Entry]
Type=Application
Exec=/home/user/.config/autostart/runme.sh
Ou para aguardar alguns segundos antes de começar (por exemplo, dê tempo à área de trabalho para inicializar antes de solicitar uma frase secreta) e execute como root, tente isto:
[Desktop Entry]
Type=Application
Exec=sudo bash -c "sleep 5; /home/user/.config/autostart/runme.sh"
Ou se precisar de mais detalhes, copie & edite um já existente (se houver algum), ou deve haver um modo de GUI para fazer um sob System → Preferências → Startup Applications , em seguida, clique em Adicionar . Ou mais linhas como essa também devem funcionar (para o XFCE, provavelmente, corte a linha OnlyShowIn):
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=test.sh
Comment=test.sh
Exec=/home/user/.config/autostart/test.sh
OnlyShowIn=XFCE;
StartupNotify=false
Terminal=true
Hidden=false
Ele apenas executa o arquivo de destino e não funciona com Exec=~/.config/autostart/test.sh
, então substitua "user" de acordo. Você provavelmente poderia usar uma linha longa em vez de apontá-la em um script bash.
Eu estou olhando para a parte de montagem agora, testando com um pc virtual. Existem algumas complicações já que você já está usando eCryptFS com uma casa criptografada, e eu testei há um tempo atrás & você não pode ter uma casa criptografada e outra pasta "Privada" criptografada em sua casa (com encrypted-setup-private
& encrypted-mount-private
), mas usando apenas ecryptfs-add-passphrase
& chamar mount.ecryptfs
/ mount -t ecryptfs
deve funcionar ...
Pule para o script abaixo para um que funcione. Aqui está o que poderia funcionar, mas eu não tive muita sorte com isso. Esses dois scripts pedem que você insira sua senha, então eles não são inseguros, embora você possa editá-la, se desejar, ou usar xenity
para inseri-la em vez de em um terminal. Aqui, o mount precisa ser executado como root, portanto, é necessário inserir chaves para o chaveiro "sudo". Rodando script inteiro como root deveria funcionar ...? Provavelmente estava latindo a árvore errada aqui.
#!/bin/bash
# mostly copied from ecryptfs-mount-private
# otherhome should be the path to the folder just outside the actual encrypted home,
# For example, /home/.ecryptfs/[user] and must be readable
otherhome=/otherpartition/home/.ecryptfs/user
decrypted=/media/decrypted
WRAPPED_PASSPHRASE_FILE="$otherhome/.ecryptfs/wrapped-passphrase"
MOUNT_PASSPHRASE_SIG_FILE="$otherhome/.ecryptfs/Private.sig"
PW_ATTEMPTS=3
MESSAGE='gettext "Enter your login passphrase:"'
if [ ! -d "$decrypted" ]; then
mkdir -p "$decrypted" || { echo "$decrypted does not exist, can not create"; exit 1; }
fi
# interactively prompt for the user's password
if [ -f "$WRAPPED_PASSPHRASE_FILE" -a -f "$MOUNT_PASSPHRASE_SIG_FILE" ]; then
tries=0
stty_orig='stty -g'
while [ $tries -lt $PW_ATTEMPTS ]; do
echo -n "$MESSAGE"
stty -echo
LOGINPASS='head -n1'
stty $stty_orig
echo
if [ $(wc -l < "$MOUNT_PASSPHRASE_SIG_FILE") = "1" ]; then
# No filename encryption; only insert fek
if printf "%ssudo bash -c ./ecryptfs-mount-single.sh [--rw] [encrypted folder] [mountpoint]
" "$LOGINPASS" | ecryptfs-unwrap-passphrase "$WRAPPED_PASSPHRASE_FILE" - | ecryptfs-add-passphrase -; then
sig='head -n1 $otherhome/.ecryptfs/Private.sig'
break
else
echo 'gettext "ERROR:"' 'gettext "Your passphrase is incorrect"'
tries=$(($tries + 1))
continue
fi
else
if printf "%s#!/bin/sh -e
#
# ecryptfs-mount-single
# Modified by Xen2050 from:
#
# ecryptfs-recover-private
# Copyright (C) 2010 Canonical Ltd.
#
# Authors: Dustin Kirkland <[email protected]>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
error() {
echo "ERROR: $@" 1>&2
echo "Usage: ecryptfs-mount-single [--rw] [encrypted private dir] [mountpoint]"
echo "\tWill attempt to mount [encrypted private dir (.Private)] to [mountpoint]"
echo "\twith standard options: ecryptfs_cipher=aes,ecryptfs_key_bytes=16"
echo "\n\t--rw\tmount with read-write access (optional)"
echo "\t[mountpoint] will attempt to be created if it does not exist"
exit 1
}
info() {
echo "INFO: $@"
}
# We need root access to do the mount
[ "$(id -u)" = "0" ] || error "This program must be run as root."
# Handle parameters
opts="ro"
if [ "$1" = "--rw" ]; then
opts="rw"
shift
fi
if [ -d "$1" ]; then
# Allow for target directories on the command line
d="$1"
# Only supplying one directory
else
error "No private directory found; it must be supplied."
fi
if [ ! -d "$2" ]; then
mkdir -p "$2" || error "mountpoint $2 does not exist, can not create"
fi
# mount directory on the command line
tmpdir=$2
# Determine if filename encryption is on
ls "$d/ECRYPTFS_FNEK_ENCRYPTED"* >/dev/null 2>&1 && fnek="--fnek" || fnek=
if [ -f "$d/../.ecryptfs/wrapped-passphrase" ]; then
info "Found your wrapped-passphrase"
echo -n "Do you know your LOGIN passphrase? [Y/n] "
lpw=$(head -n1)
case "$lpw" in
y|Y|"")
# Use the wrapped-passphrase, if available
info "Enter your LOGIN passphrase..."
ecryptfs-insert-wrapped-passphrase-into-keyring "$d/../.ecryptfs/wrapped-passphrase"
sigs=$(sed -e "s/[^0-9a-f]//g" "$d/../.ecryptfs/Private.sig")
use_mount_passphrase=0
;;
*)
use_mount_passphrase=1
;;
esac
else
# Fall back to mount passphrase
info "Could not find your wrapped passphrase file."
use_mount_passphrase=1
fi
if [ "$use_mount_passphrase" = "1" ]; then
info "To recover this directory, you MUST have your original MOUNT passphrase."
info "When you first setup your encrypted private directory, you were told to record"
info "your MOUNT passphrase."
info "It should be 32 characters long, consisting of [0-9] and [a-f]."
echo
echo -n "Enter your MOUNT passphrase: "
stty_orig=$(stty -g)
stty -echo
passphrase=$(head -n1)
stty $stty_orig
echo
sigs=$(printf "%s[Desktop Entry]
Type=Application
Exec=/home/user/.config/autostart/runme.sh
" "$passphrase" | ecryptfs-add-passphrase $fnek | grep "^Inserted" | sed -e "s/^.*\[//" -e "s/\].*$//" -e "s/[^0-9a-f]//g")
fi
case $(echo "$sigs" | wc -l) in
1)
mount_sig=$(echo "$sigs" | head -n1)
fnek_sig=
mount_opts="$opts,ecryptfs_sig=$mount_sig,ecryptfs_cipher=aes,ecryptfs_key_bytes=16"
;;
2)
mount_sig=$(echo "$sigs" | head -n1)
fnek_sig=$(echo "$sigs" | tail -n1)
mount_opts="$opts,ecryptfs_sig=$mount_sig,ecryptfs_fnek_sig=$fnek_sig,ecryptfs_cipher=aes,ecryptfs_key_bytes=16"
;;
*)
continue
;;
esac
(keyctl list @u | grep -qs "$mount_sig") || error "The key required to access this private data is not available."
(keyctl list @u | grep -qs "$fnek_sig") || error "The key required to access this private data is not available."
if mount -i -t ecryptfs -o "$mount_opts" "$d" "$tmpdir"; then
info "Success! Private data mounted at [$tmpdir]."
else
error "Failed to mount private data at [$tmpdir]."
fi
" "$LOGINPASS" | ecryptfs-insert-wrapped-passphrase-into-keyring "$WRAPPED_PASSPHRASE_FILE" - ; then
sig='head -n1 $otherhome/.ecryptfs/Private.sig'
fnek_sig='tail -n1 $otherhome/.ecryptfs/Private.sig'
break
else
echo 'gettext "ERROR:"' 'gettext "Your passphrase is incorrect"'
tries=$(($tries + 1))
continue
fi
fi
done
if [ $tries -ge $PW_ATTEMPTS ]; then
echo 'gettext "ERROR:"' 'gettext "Too many incorrect password attempts, exiting"'
exit 1
fi
if [ -v fnek_sig ]; then
# filename encryption enabled, $fnek_sig has been set
mount -i -t ecryptfs -o ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_sig=$sig,ecryptfs_fnek_sig=$fnek_sig $otherhome/.Private $decrypted
else
# no filename encryption
mount -i -t ecryptfs -o ecryptfs_cipher=aes,ecryptfs_key_bytes=16,ecryptfs_sig=$sig $otherhome/.Private $decrypted
fi
else
echo 'gettext "ERROR:"' 'gettext "Encrypted private directory is not setup properly"'
exit 1
fi
if grep -qs "$otherhome/.Private $decrypted ecryptfs " /proc/mounts 2>/dev/null; then
echo
echo 'gettext "INFO:"' 'gettext "Your private directory has been mounted."'
echo
fi
exit 0
Este script funciona,
embora eu tenha problemas para executar qualquer script executável de dentro de uma casa criptografada. Tive que chamá-lo como um argumento para bash
/ sh
, com
[Desktop Entry]
Type=Application
Exec=sudo bash -c "sleep 5; /home/user/.config/autostart/runme.sh"
Aqui está:
[Desktop Entry]
Encoding=UTF-8
Version=0.9.4
Type=Application
Name=test.sh
Comment=test.sh
Exec=/home/user/.config/autostart/test.sh
OnlyShowIn=XFCE;
StartupNotify=false
Terminal=true
Hidden=false
Desmontando antes / quando desconectando, e talvez removendo as chaves do chaveiro do kernel (com keyctl
clear ou purge, sudo keyctl clear @u
limpa tudo) provavelmente são boas idéias. Eu tinha uma segunda pasta montada dentro de uma casa criptografada e desconectada, ela aparentemente desmontava a segunda pasta (não em / proc / mounts), mas ainda aparecia em mount
.