我已经为自己建立了一个很好的设置:
我已经加密了可使用 autofs 安装的 encfs 文件夹,即当我输入文件夹时,它们将自动解密。我将 encfs 密码添加到我的密钥环中,并编写了一个提取密码的自定义脚本(/usr/local/sbin/load-encfs
见下文)。
唯一的缺点是,我必须在第一次访问任何自动安装的文件夹时输入登录密码才能解锁密钥环。每次访问另一个文件夹(或超时后的相同文件夹)都不会提示我输入密码。
问题:是否有可能第一个密码提示也可以以某种方式自动化?
/etc/autofs/auto.master
:
我刚刚添加了这一行:
/- /etc/autofs/auto.encfs
/etc/autofs/auto.encfs
:
/home/user/Privat -fstype=fuse :load-encfs\#user\:/home/user/encfs-keys/private.xml\:/home/user/Dropbox/.private
/home/user/BTU -fstype=fuse :load-encfs\#user\:/home/user/encfs-keys/btu.xml\:/home/user/Dropbox/.btu
/home/user/TUD -fstype=fuse :load-encfs\#user\:/home/user/encfs-keys/tud.xml\:/home/user/Dropbox/.tud
/usr/local/sbin/load-encfs
(鱼脚本):
#!/usr/bin/fish
function usage
echo "need at least two arguments"
echo " 1. <user name>:[<config>]:<crypt folder>"
echo " 2. <mount folder>"
exit 1
end
if test (count $argv) -lt 2
usage
end
set split (string split ':' $argv[1])
if test $status -ne 0
usage
else if test (count $split) -eq 2
set USER_NAME $split[1]
set CONFIG_PATH ""
set CRYPT_PATH (realpath $split[2])
else
set USER_NAME $split[1]
set CONFIG_PATH (realpath $split[2])
set CRYPT_PATH (realpath $split[3])
end
set MOUNT_PATH (realpath $argv[2])
set PID (ps aux | sed -e '/sed/d;/$USER_NAME.*xinit/!d;s/^.*xserverrc \(:[0-9\.]*\).*/aaa/' | awk '{ print $2 }')
if test -n "$PID"
set DISPLAY (cat /proc/$PID/environ | tr '\0' '\n' | grep '^DISPLAY=' | sed -r 's/.*=(.*)/\1/')
end
if test -z "$DISPLAY"
set DISPLAY ":0.0"
end
set PASS (env DISPLAY=$DISPLAY sudo -H -u $USER_NAME secret-tool lookup server $CRYPT_PATH)
if test -n $CONFIG_PATH
set COMMAND "env ENCFS6_CONFIG=$CONFIG_PATH"
end
set COMMAND $COMMAND "encfs --public --extpass='echo \'$PASS\'' $CRYPT_PATH $MOUNT_PATH"
eval $COMMAND
我添加了各种参数以灵活存储 encfs 的配置文件。
答案1
更新后遇到 dbus 问题后,我终于找到了解决方案。新脚本:
#!/usr/bin/fish
function usage
echo "need at least two arguments"
echo " 1. <user name>:[<config>]:<crypt folder>"
echo " 2. <mount folder>"
exit 1
end
if test (count $argv) -lt 2
usage
end
set split (string split ':' $argv[1])
if test $status -ne 0
usage
else if test (count $split) -eq 2
set USER_NAME $split[1]
set CONFIG_PATH ""
set CRYPT_PATH (realpath $split[2])
else
set USER_NAME $split[1]
set CONFIG_PATH (realpath $split[2])
set CRYPT_PATH (realpath $split[3])
end
set MOUNT_PATH (realpath $argv[2])
set PASS (sudo -H -u $USER_NAME bash -c "env DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/`id -u $USER_NAME`/bus secret-tool lookup server $CRYPT_PATH")
if test -n $CONFIG_PATH
set COMMAND "env ENCFS6_CONFIG=$CONFIG_PATH"
end
set COMMAND $COMMAND "encfs --public --extpass='echo \'$PASS\'' $CRYPT_PATH $MOUNT_PATH"
eval $COMMAND