当前位置: 首页 > 工具软件 > EncFS > 使用案例 >

使用encfs

夹谷浩博
2023-12-01

1) 安装apt-get install encfs

2) 在/sbin下建立enc 和enc_pub

#!/bin/bash

usage() {
BASE=$(basename $0)
echo "Usage examples:"
echo -e "\t$BASE cryptdir mountpoint (assumes mount or create)"
echo -e "\t$BASE mountpoint (assumes umount)"
exit 0
}

[ "$#" == "1" ] || [ "$#" == "2" ] || usage

ENCFS=$(which encfs)
FUSERMOUNT=$(which fusermount)

[ -z "$ENCFS" ] && {
echo "I can't find 'encfs'. Make sure you installed the encfs package." >&2
exit 1
}

[ -z "$FUSERMOUNT" ] && {
echo "I can't find 'fusermount'. Make sure you installed the fuse-utils package." >&2
exit 1
}

# mount or create
[ "$#" == "2" ] && {
[ -d "$1" ] && [ -d "$2" ] || {
echo "You must supply two dir names for cryptdir and mountpoint." >&2
exit 1
}
DO=$(pwd)
cd "$1" && D1=$(pwd) || exit 2
cd "$DO" || exit 2
cd "$2" && D2=$(pwd) || exit 2
cd "$DO" || exit 2
"$ENCFS" "$D1" "$D2" && \
echo "Encrypted filesystem now mounted" || \
{ echo "Could not mount filesystem. Bad password or already mounted." >&2; exit 3; }
}

# umount
[ "$#" == "1" ] && {
[ -d "$1" ] || {
echo "You must supply a dir name as mountpoint." >&2
exit 1
}
"$FUSERMOUNT" -u "$1" && \
echo "Encrypted filesystem has been umounted" || \
{ echo "Could not umount directory" >&2; exit 3; }
}

3) 使用

enc 加密文件 工作文件夹


 类似资料: