├── .gitignore ├── gocryptfs-ui.png ├── gocryptfs-ui.desktop ├── Makefile ├── gocryptfs-ui-setup ├── README.md └── gocryptfs-ui /.gitignore: -------------------------------------------------------------------------------- 1 | README.html 2 | -------------------------------------------------------------------------------- /gocryptfs-ui.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bulletmark/gocryptfs-ui/HEAD/gocryptfs-ui.png -------------------------------------------------------------------------------- /gocryptfs-ui.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Type=Application 3 | Terminal=false 4 | Name=Gocryptfs-UI 5 | Exec=/usr/bin/gocryptfs-ui -i60 .Private Private 6 | Icon=gocryptfs-ui 7 | Categories=Security;Settings; 8 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | NAME = gocryptfs-ui 2 | 3 | all: 4 | @echo "Type make install|uninstall|check" 5 | 6 | install: 7 | @./$(NAME)-setup -d "$(DESTDIR)" install 8 | 9 | uninstall: 10 | @./$(NAME)-setup -d "$(DESTDIR)" uninstall 11 | 12 | check: 13 | shellcheck $(NAME) $(NAME)-setup 14 | -------------------------------------------------------------------------------- /gocryptfs-ui-setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # User setup script. 3 | # (C) Mark Blakeney, Aug 2016. 4 | 5 | PROG="$(basename $0)" 6 | NAME=${PROG%-*} 7 | 8 | BINDIR="/usr/bin" 9 | APPDIR="/usr/share/applications" 10 | ICOBAS="/usr/share/icons/hicolor" 11 | ICODIR="$ICOBAS/128x128/apps" 12 | DOCDIR="/usr/share/doc/$NAME" 13 | 14 | usage() { 15 | echo "Usage:" 16 | echo "sudo $PROG install|uninstall" 17 | echo 18 | echo "(-d option sets DESTDIR for install/uninstall)" 19 | exit 1 20 | } 21 | 22 | # Process command line options 23 | DESTDIR="" 24 | while getopts d: c; do 25 | case $c in 26 | d) DESTDIR="$OPTARG";; 27 | \?) usage;; 28 | esac 29 | done 30 | 31 | shift $((OPTIND - 1)) 32 | 33 | if [[ $# -ne 1 ]]; then 34 | usage 35 | fi 36 | 37 | cmd="$1" 38 | 39 | if [[ $cmd == install || $cmd == uninstall ]]; then 40 | DESTDIR="${DESTDIR%%+(/)}" 41 | if [[ -z $DESTDIR && $(id -un) != root ]]; then 42 | echo "Install or uninstall must be run as sudo/root." 43 | exit 1 44 | fi 45 | 46 | if [[ $cmd == install ]]; then 47 | install -CDv -m 755 -t $DESTDIR$BINDIR $NAME-setup 48 | install -CDv -m 755 -t $DESTDIR$BINDIR $NAME 49 | install -CDv -m 644 -t $DESTDIR$APPDIR $NAME.desktop 50 | install -CDv -m 644 -t $DESTDIR$ICODIR $NAME.png 51 | install -CDv -m 644 -t $DESTDIR$DOCDIR README.md 52 | else 53 | rm -rfv $DESTDIR$BINDIR/$NAME 54 | rm -rfv $DESTDIR$APPDIR/$NAME.desktop 55 | rm -rfv $DESTDIR$ICODIR/$NAME.png 56 | rm -rfv $DESTDIR$DOCDIR 57 | rm -rfv $DESTDIR$BINDIR/$NAME-setup 58 | fi 59 | 60 | if [[ -z $DESTDIR ]]; then 61 | if [[ -x /usr/bin/gtk-update-icon-cache ]]; then 62 | /usr/bin/gtk-update-icon-cache $ICOBAS 63 | fi 64 | if [[ -x /usr/bin/update-desktop-database ]]; then 65 | /usr/bin/update-desktop-database -q 66 | fi 67 | fi 68 | else 69 | usage 70 | fi 71 | 72 | exit 0 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## ENCRYPTED FILESYSTEM [GOCRYPTFS](https://nuetzlich.net/gocryptfs/) GUI WRAPPER 2 | [![AUR](https://img.shields.io/aur/version/gocryptfs-ui)](https://aur.archlinux.org/packages/gocryptfs-ui/) 3 | 4 | [Gocryptfs-ui](https://github.com/bulletmark/gocryptfs-ui) is a bash 5 | script which provides a simple GUI around the 6 | [gocryptfs](https://nuetzlich.net/gocryptfs/) command line utility to 7 | mount and unmount an encrypted directory. This script requires 8 | [gocryptfs](https://nuetzlich.net/gocryptfs/), 9 | [zenity](https://wiki.gnome.org/Projects/Zenity), and 10 | [xdg-open](https://linux.die.net/man/1/xdg-open). 11 | 12 | Whenever you want to mount your private directory, you click on the 13 | desktop launcher. The launcher runs the script with appropriate 14 | directory arguments. The script uses 15 | [zenity](https://wiki.gnome.org/Projects/Zenity) to prompt you for the 16 | password and then mounts the 17 | [gocryptfs](https://nuetzlich.net/gocryptfs/) directory. If you click on 18 | the launcher when the private directory is already mounted, then you are 19 | prompted to unmount it. The prompt windows are [displayed in the 20 | wiki](https://github.com/bulletmark/gocryptfs-ui/wiki). There are some 21 | other options, see the usage below. 22 | 23 | My motivation for creating this utility is to provide: 24 | 25 | 1. One mouse click and password entry to access and open a single 26 | encrypted personal directory. 27 | 2. One mouse click to close the directory. 28 | 3. No background application running. 29 | 4. No password cached anywhere. 30 | 31 | The latest version and documentation is available at 32 | http://github.com/bulletmark/gocryptfs-ui. 33 | 34 | _NOTE: This project supercedes my older 35 | [encfsui](https://github.com/bulletmark/encfsui) project_. 36 | 37 | ### INSTALLATION 38 | 39 | NOTE: Arch users can just install [_gocryptfs-ui from the 40 | AUR_](https://aur.archlinux.org/packages/gocryptfs-ui/) and skip to the 41 | next section. Other users can install by running: 42 | 43 | # Install gocryptfs zenity xdg-utils 44 | git clone http://github.com/bulletmark/gocryptfs-ui 45 | cd gocryptfs-ui 46 | sudo make install (or sudo ./gocryptfs-ui-setup install) 47 | 48 | ### USAGE 49 | 50 | The installation procedure creates a desktop application _gocryptfs-ui_ 51 | which you can run from your DE. By default, _gocryptfs-ui_ mounts your 52 | encrypted `~/.Private` dir to unencrypted `~/Private` with an 53 | in-activity timeout of 60 minutes. So you should first create an 54 | [gocryptfs](https://nuetzlich.net/gocryptfs/) `~/.Private` directory, or 55 | create a link to there from where you keep your encrypted directory. 56 | See [`man 57 | gocryptfs`](https://github.com/rfjakob/gocryptfs/blob/master/Documentation/MANPAGE.md) 58 | for details on how to create a new encrypted directory. 59 | 60 | You can also copy the `/usr/share/applications/gocryptfs-ui.desktop` 61 | launcher to your own Desktop Launcher in `~/.local/share/applications/` 62 | to use different source or target directory names, or to change the 63 | timeout, etc. 64 | 65 | The utility can also be run from the command line. The usage is: 66 | 67 | gocryptfs-ui [-options] source_enc_dir target_mount_dir 68 | 69 | GUI utility to mount source_enc_dir to target_mount_dir. 70 | If target already mounted then it will be unmounted instead. 71 | 72 | Options: 73 | -i specify idle timeout mins 74 | -o (don't open target dir in file browser) 75 | 76 | ### UPGRADE 77 | 78 | cd gocryptfs-ui # Source dir, as above 79 | git pull 80 | sudo make install (or sudo ./gocryptfs-ui-setup install) 81 | 82 | ### LICENSE 83 | 84 | Copyright (C) 2021 Mark Blakeney. This program is distributed under the 85 | terms of the GNU General Public License. 86 | 87 | This program is free software: you can redistribute it and/or modify it 88 | under the terms of the GNU General Public License as published by the 89 | Free Software Foundation, either version 3 of the License, or any later 90 | version. 91 | 92 | This program is distributed in the hope that it will be useful, but 93 | WITHOUT ANY WARRANTY; without even the implied warranty of 94 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 95 | Public License at for more details. 96 | 97 | 98 | -------------------------------------------------------------------------------- /gocryptfs-ui: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ############################################################################### 3 | # This bash script provides a simple gui around the gocryptfs command line 4 | # utility to mount and unmount an encrypted directory. This script 5 | # requires gocryptfs, zenity, and xdg-open. See accompaning README.md. 6 | # 7 | # Return code = 0 if no error, else 1. 8 | # 9 | # Copyright (C) 2021 Mark Blakeney. This program is distributed under 10 | # the terms of the GNU General Public License. This program is free 11 | # software: you can redistribute it and/or modify it under the terms of 12 | # the GNU General Public License as published by the Free Software 13 | # Foundation, either version 3 of the License, or any later version. 14 | # This program is distributed in the hope that it will be useful, but 15 | # WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | # General Public License at for more 18 | # details. 19 | # 20 | # See http://github.com/bulletmark/gocryptfs-ui>. 21 | # This project is based on my older encfsui project, see 22 | # http://github.com/bulletmark/encfsui>. 23 | # Mark Blakeney, May 2021. 24 | ############################################################################### 25 | 26 | usage() { 27 | echo "Usage: $(basename "$0") [-options] source_enc_dir target_mount_dir" 28 | echo "GUI utility to mount source_enc_dir to target_mount_dir." 29 | echo "If target already mounted then it will be unmounted instead." 30 | echo "Options:" 31 | echo "-i specify idle timeout mins" 32 | echo "-o (don't open target dir in file browser)" 33 | exit 1 34 | } 35 | 36 | PROG="gocryptfs" 37 | 38 | # Process command line options 39 | MINS="" 40 | NOOPEN=0 41 | while getopts i:o? c; do 42 | case $c in 43 | i) MINS="-idle ${OPTARG}m";; 44 | o) NOOPEN=1;; 45 | ?) usage;; 46 | esac 47 | done 48 | 49 | shift $((OPTIND - 1)) 50 | 51 | if [[ $# -ne 2 ]]; then 52 | usage 53 | fi 54 | 55 | # Read source and target dirs. Make absolute path. 56 | src=$(readlink -f "$1") 57 | tgt=$(readlink -f "$2") 58 | 59 | # Check usage 60 | if [[ -z $src || -z $tgt ]]; then 61 | usage 62 | fi 63 | 64 | # Function to output message using graphical prompt 65 | gui() { 66 | local title="$1" 67 | local type="$2" 68 | local text="$3" 69 | 70 | if [[ $type == entry ]]; then 71 | args="--hide-text" 72 | else 73 | args="--ellipsize --" 74 | fi 75 | 76 | # Send errors to null to avoid spurious GTK warnings. 77 | zenity --$type --title="$title $PROG directory" \ 78 | --text="$text" --modal $args 79 | } 80 | 81 | if ! type "$PROG" &>/dev/null; then 82 | gui Mount error \ 83 | "Sorry, $PROG is not installed.\n\nInstall it via your package manager." 84 | exit 1 85 | fi 86 | 87 | # Check if this target is already mounted 88 | if mount | grep -q " on $tgt "; then 89 | # Prompt to unmount 90 | if ! gui Mount question \ 91 | "$tgt is already mounted.\n\nDo you want to unmount it?"; then 92 | exit 0 93 | fi 94 | 95 | # Unmount it 96 | res=$(fusermount -u "$tgt" 2>&1) 97 | 98 | # Output an error if the unmount failed 99 | if [[ $? -ne 0 ]]; then 100 | gui Unmount error "$res" 101 | exit 1 102 | fi 103 | 104 | # Remove target dir if it is empty 105 | rmdir "$tgt" &>/dev/null 106 | exit 0 107 | fi 108 | 109 | open-dir-gui() { 110 | local dir="$1" 111 | xdg-open "$dir" &>/dev/null & 112 | } 113 | 114 | # Mount the directory. Check first that this is the correct type of filesystem 115 | if ! "$PROG" -info "$src" &>/dev/null; then 116 | gui Mount error \ 117 | "$src does not exist or is not an $PROG filesystem.\nCreate it manually with $PROG. E.g. Run the following and answer the prompts:\n\nmkdir -p $src; $PROG -init $src\n\nSee man gocryptfs for more options and details." 118 | exit 1 119 | fi 120 | 121 | # Create target dir if it doesn't exist 122 | mkdir -p "$tgt" &>/dev/null 123 | 124 | # Loop on user entry for password .. 125 | mounted=0 126 | while true; do 127 | 128 | # Get password from user 129 | if ! password=$(gui Mount entry "Mount $src to $tgt\n\nWhat is the password?"); then 130 | break 131 | fi 132 | 133 | # Give password to $PROG and mount the file system 134 | res=$("$PROG" -passfile <(printf %s "$password") $MINS "$src" "$tgt" 2>&1) 135 | 136 | # Check for error (typically a bad password) 137 | if [[ $? -eq 0 ]]; then 138 | if [[ $NOOPEN -eq 0 ]]; then 139 | open-dir-gui "$tgt" 140 | fi 141 | 142 | mounted=1 143 | break 144 | fi 145 | 146 | gui Mount error "$res" 147 | done 148 | 149 | if [[ $mounted -eq 0 ]]; then 150 | rmdir "$tgt" &>/dev/null 151 | fi 152 | 153 | exit 0 154 | --------------------------------------------------------------------------------