Created
June 23, 2017 18:28
-
-
Save matheusd/be108e5c07f934a0d69fc084a27f21ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DEVICE=$1 | |
TARGETVM=$2 | |
USB_DEVICE=`qvm-usb |grep $DEVICE |cut -f1` | |
# Is it already attached | |
qvm-usb |grep $USB_DEVICE | grep "(attached to " | |
if [ $? -eq 0 ]; then | |
echo "detatching $DEVICE" | |
qvm-usb -d $USB_DEVICE | |
sleep 1 | |
fi | |
echo "attaching $DEVICE to $TARGETVM" | |
qvm-usb -a $TARGETVM $USB_DEVICE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Credits to https://micahflee.com/2016/12/qubes-tip-making-yubikey-openpgp-smart-cards-slightly-more-usable/ for the inspiration & initial version.