欢迎光临
我们一直在努力

在Linux中使用USB作为安全密钥

1. 使用命令查询vendor ID and device ID

$ lsusb

2. As root, create a new file named 80-usb.rules in /etc/udev/rules.d/ directory and paste these lines –

ACTION=="add", SUBSYSTEMS=="usb", ATTR{idVendor}=="<vendor-id>", ATTR{idProduct}=="<device-id>", RUN+="/usr/local/bin/usb-lock.sh unlock"
ACTION=="remove", SUBSYSTEMS=="usb", ENV{ID_VENDOR_ID}=="<vendor-id>", ENV{ID_MODEL_ID}=="<device-id>", RUN+="/usr/local/bin/usb-lock.sh lock"

3. Create the usb-lock.sh file in /usr/local/bin/ directory, and paste this –

#!/bin/bash
session=$(loginctl|grep '<username>'|awk '{print $1;}')
if [ ${1} == "lock" ]
then
loginctl lock-session ${session}
elif [ ${1} == "unlock" ]
then
loginctl unlock-session ${session}
fi

4. Replace <username> in 2nd line with your username.

chmod +x /usr/local/bin/usb-lock.sh
sudo udevadm control --reload
赞(0)
未经允许不得转载:自游互动 » 在Linux中使用USB作为安全密钥
分享到: 更多 (0)

自由技术,自由自在

项目合作联系我们