Yubikey 新手使用指南
前几天 Cloudfalre
和 yubikey
推出了合作活动,使用优惠代码购买 yubikey
只要很低价格就能购买。之前没玩过 yubikey
,所以决定体验下 yubikey
的使用方法。
macOS 使用 yubikey
登陆
- 下载
yubikey manager
点击跳转
- 点击
Application
下的PIV
首次请点击 PIN Management ->
Configure PINs->
Current PINs右侧的
Use default PINs` -> 设置密码。
同样的方法更改 PUK。
然后点击 Manage Key
-> 右侧的 Generate
-> 然后勾选 Protect with PIN
完成后,点击 Application -> PIV 旁边的 Setup for macOS
然后根据指示操作就好了.
让 macOS 仅使用 yubikey 登陆
此操作存在危险!!!确认安全后再开启!!!
在终端中输入以下命令:
sudo defaults write /Library/Preferences/com.apple.security.smartcard enforceSmartCard -bool true
macOS 使用 yubikey 来认证 ssh 登陆
安装 Brew.
略。
安装环境
brew install gnupg
brew install ykman
生成密钥
运行:
gpg --card-edit
>admin
>generate
编辑 ~/.gnupg/gpg-agent.conf
只需加入下列一段
enable-ssh-support
此时仍无法导出 ssh-key
$ ssh-add -L
The agent has no identities.
编辑 ~/.zshrc
或者 ~/.bashrc
export GPG_TTY="$(tty)"
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
重新打开终端
检查 ssh-add -L
是否工作并导出公钥
ssh 连接出错 sign_and_send_pubkey: signing failed: agent refused operation
可能是 GPG_TTY
设置错误。
检查环境下 有无以下参数
GPG_TTY=$(tty)
export GPG_TTY
也有可能未更新 TTY,终端下输入
gpg-connect-agent updatestartuptty /bye
另外一种解决方法
编辑 ~/.zshrc
或者 ~/.bashrc
alias ssh="gpg-connect-agent updatestartuptty /bye > /dev/null; ssh"
alias scp="gpg-connect-agent updatestartuptty /bye > /dev/null; scp"
需要触摸才能认证
每当尝试使用 YubiKey 进行 ssh 身份验证时,如果要求触摸一下才能继续,可以防止流氓进程在插入密钥时使用它。
你可以使用YubiKey Manager CLI
安装后,使用 ykman openpgp touch
子命令配置触摸设置:
ykman openpgp set-touch aut on
ykman openpgp set-touch enc on
ykman openpgp set-touch sig on
Google
使用 yubikey
https://support.google.com/accounts/answer/6103523
Microsoft
帐户使用 yubikey
Windows
使用 yubikey
下载 yubikey manager
链接地址: Yubikey 官网