Coder Social home page Coder Social logo

jerichojyant / usbkey Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 0.0 21 KB

A bash script for locking and unlocking an encrypted USB flash drive. This script also lets you easily activate an SSH key stored on the drive.

License: MIT License

Shell 100.00%

usbkey's People

Contributors

jerichojyant avatar

Stargazers

 avatar  avatar

Watchers

 avatar

usbkey's Issues

Clarify removal of SSH key from system after locking/shutting down USBKey

josh@[hostname]:~$ usbkey ssh
Enter passphrase for /media/josh/keysandbackups/id_rsa: 
Bad passphrase, try again for /media/josh/keysandbackups/id_rsa: 
SSH key loaded

Note: Locking or shuting down your USBKey will not remove the SSH key
It will persist until you end this terminal session

"It will persist until you end this terminal session" is not exactly accurate. It persists on all terminal sessions that the user successfully ran "usbkey go", "usbkey ssh", or otherwise added it to the ssh-agent. Given the security driven nature of this project, it seems vital to be precise.

'loadSSHKey' function (called by 'ssh' and 'go' commands) always reports success, even when SSH key loading fails

Problem

When running the usbkey ssh or usbkey go, the loadSSHKey function will display a success message even if the USBKey is locked or not present. The user is told that the SSH key is loaded, and it is not.

josh@[hostname]:~$ usbkey ssh
/media/josh/keysandbackups/id_rsa: No such file or directory

SSH key loaded
Note: Locking or shuting down your USBKey will not remove the SSH key
It will persist until you end this terminal session

Solution

Change error handling approach in loadSSHKey function to the approach used by the other functions (String comparison with captured command output)

Check if USBKey is already unlocked and mounted before trying to do so

Problem:

When attempting to unlock a USBKey that has already been unlocked and mounted, the script does not check to see if the device is mounted. It instead tries to unlock it again. It handles the resulting error correctly, but it should not ask for a passphrase that's not needed.

josh@[hostname]:~$ usbkey unlock
Passphrase: 

USBKey 'keysandbackups' already unlocked

This is inconvenient and wastes the end user's time. This should be the output:

josh@[hostname]:~$ usbkey unlock
USBKey 'keysandbackups' already unlocked

Solution

The passphrase prompt is given by the udisksctl unlock... command in the bash script's unlockUSBDrive. This command is redundant when the device is already unlocked.

Check to see if the device is mounted using a shell command before running any udisksctl commands and output the "already unlocked" message.

usbkey bash script and README.md contain spelling errors

I tried out VS Code when creating usbkey. It does not have spell check by default (I'm spoiled by JetBrains). There are spelling errors in the readme, and the bash script has spelling errors in both the source code and its console output.

It's a quick fix but I'm leaving it open for anyone who's new to GitHub or open source contributions.

usbkey command to walk the user through creating a USBKey (format and encrypt device)

The setup for a USBKey isn't that hard -- but it may be intimidating, and users need to understand the dangers as well as be given help showing which device they are about to wipe.

The commands are simple enough that they could be scripted, and with the script giving a warning and a link to an overview, the amount of information needed is minimal -- just the name of the disk (such as "/dev/sda"), and the desired name of the USBKey (such as "keysandbackups"). We could optionally give the user a choice of filesystem (ext4 vs xfs).

The main issue is confirming that the user is hitting the right device, and that could be done through grepping some detailed output about the current disk devices (I found the command while researching this project but forgot what it is... found it: udisksctl info -b /dev/sda might help).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.