Created
September 18, 2015 09:32
-
-
Save mopemope/6f7b36e52511948f9679 to your computer and use it in GitHub Desktop.
YubiKey NEO で Linux でも 2段階認証しよう! ref: http://qiita.com/mopemope/items/779a5a4da734914b9cd0
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
$ packer -S yubikey-personalization yubikey-personalization-gui yubikey-neo-manager |
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
$ yubikey-personalization-gui |
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
$ ssh -YC ma2@xxxxxxx | |
Authenticated with partial success. | |
YubiKey for `ma2': |
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
auth sufficient pam_yubico.so mode=challenge-response chalresp_path=/etc/yubico |
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
$ ykpersonalize -2 -ochal-resp -ochal-hmac -ohmac-lt64 -oserial-api-visible | |
... | |
Commit? (y/n) [n]: y | |
$ |
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
$ mkdir $HOME/.yubico | |
$ ykpamcfg -2 -v | |
... | |
Stored initial challenge and expected response in '/home/user/.yubico/challenge-123456'. | |
$ |
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
$ mkdir /etc/yubico | |
$ chmod +t /etc/yubico | |
$ chmod 777 /etc/yubico | |
$ mv /home/user/.yubico/challenge-####### /etc/yubico/username-####### | |
... | |
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
auth required pam_u2f.so authfile=/etc/u2f_mappings |
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
<username1>:<KeyHandle1>,<UserKey1>:<KeyHandle2>,<UserKey2>:... | |
<username2>:<KeyHandle1>,<UserKey1>:<KeyHandle2>,<UserKey2>:... |
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
$ pamu2fcfg -u <username> |
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
$ sudo ls | |
Please touch the device. | |
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
$ udevadm monitor --environment –udev |
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
$ neoman |
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
# Yubikey Udev Rule: running a bash script in case your Yubikey is removed | |
ACTION=="remove", ENV{ID_VENDOR_ID}=="1050", ENV{ID_MODEL_ID}=="0116", ENV{ID_SERIAL_SHORT}=="00000000000", RUN+="/usr/local/bin/yubikey-lock" |
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 | |
user=`ps aux | grep -v root | grep gdm-x-session | head -n 1 | awk '{print $1}'` | |
sessionid=`/bin/loginctl list-sessions | grep ${user} | awk '{print $1}'` | |
if [ -z "$(lsusb | grep Yubico)" ]; then | |
logger "YubiKey Removed" | |
/bin/loginctl lock-session $sessionid | |
fi |
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
$ packer -S yubico-pam pam_u2f |
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
auth sufficient pam_yubico.so id={Your ID} key={Your Key} authfile=/etc/yubikey_mappings |
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
<first user name>:<Yubikey token ID1>:<Yubikey token ID2>:…. | |
<second user name>:<Yubikey token ID3>:<Yubikey token ID4>:…. |
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
$ cccccccgklgcvnkcvnnegrnhgrjkhlkfhdkclfncvlgj | |
bash: cccccccgklgcvnkcvnnegrnhgrjkhlkfhdkclfncvlgj: command not found |
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
`Modhex encoded: XXXXXXX` |
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
auth required pam_yubico.so id=xxxxxx key=xxxxxxxxxxxxxxxxxxxxxx authfile=/etc/yubikey_mappings | |
auth include system-remote-login | |
account include system-remote-login | |
password include system-remote-login | |
session include system-remote-login |
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
... | |
UsePAM yes | |
PasswordAuthentication no | |
ChallengeResponseAuthentication yes | |
AuthenticationMethods publickey,keyboard-interactive | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment