職場でyubikeyの展開を自動化しようとしています。

職場でyubikeyの展開を自動化しようとしています。

リンクされたyubikeyでgpg --card-editコマンドを実行し、カードにRSA 4096キーペアを生成する基本スクリプトを作成しようとしています。

#!/usr/bin/env bash

red=`tput setaf 1`
green=`tput setaf 2`
reset=`tput sgr0`  
set -euf
set -o pipefail

echo "${red}script started${reset}"

echo " ${red}run card edit ${reset}"
gpg --card-edit --command-fd - < ~/bin/yubikey/input2.txt

input2.txtには、実行したいコマンドが含まれています。

admin
generate

gpgから取得したPINプロンプトを処理する方法が見つからないため、このエラーが発生します。

gpg: error checking the PIN: Inappropriate ioctl for device

ベストアンサー1

パーティーに少し遅れましたが、おそらく未来の私を含む誰かがこれを感謝しています... :-)

git clone https://github.com/santiago-mooser/yubikey-provisioning-scripts.git
cd yubikey-provisioning-scripts
./yubikey_provision.sh -h
   This script provisions a yubikey by generating a master key, 3 subkeys and moving the subkeys to the yubikey. Please read the documentation for more information.

   Usage: yubikey_provision.sh [-e|--email EMAIL_ADDRESS] [-u|--user-pin USER_PIN] [-a|--admin-pin ADMIN_PIN] [-y|--yes]

   optional arguments:
     -h, --help           show this help message and exit.
     -e, --email          provide email used for PGP key. If it is not provided, the user is prompted for an email.
     -f, --first-name     provide first name used for PGP key. Defaults to an empty string.
     -l, --last-name      provide last name used for PGP key. Defaults to an empty string.
     -c, --comment        provide comment used for PGP key. Defaults to an empty string.
         --username       provide username used for PGP key. Defaults to an empty string.
     -p, --password       provide password used for PGP key. If it is not provided, a random one is generated.
     -u, --user-pin       provide new user pin for the yubikey. If none is provided, a random one is generated.
     -a, --admin-pin      provide new admin pin for the yubikey. If none is provided, a random one is generated.
     -y, --yes            skips prompts to reset the yubikey.
     -v, --version        prints out the version number.

このスクリプトは、他のすべてのヘルパースクリプトを正しい順序と正しいフラグで実行して、新しい秘密鍵、サブキーを生成し、関連付けられたyubikeyのopenPGPアプレットをリセットし、サブキーをyubikeyにアップロードするのに役立ちます。

警告する

このスクリプトはまた、公開鍵をopenPGPの公開鍵サーバーにアップロードします。これが望ましくない場合は、スクリプトで無効にします。

警告する

読む読む.mdここ!

https://github.com/santiago-mooser/yubikey-provisioning-scripts

警告する

yubikeyの秘密鍵はエクスポートされません。秘密鍵をエクスポートするには、363-365スクリプトyubikey_provision.sh行のコメントを外します。

または、新しいサブキーを再構成するには、この公式のyubikeyガイドに従って新しいサブキーを生成しますが、オプション14を選択して残りのガイドを続行します(サブキーをyubikeyに移動することを含む)。

警告する

互換性

このスクリプトは、MacOS Monetrrey、Ventura、およびUbutuntu 20.04 LTS以降でテストされました。以前のバージョンでも機能できますが、保証されません。

おすすめ記事