Kali Linux on WSL 2 で pbcopy 出来ない時
結論
xsel --clipboard
じゃなくて clip.exe
を使おう.
e.g. SSH 公開鍵のコピー
cat ~/.ssh/id_ed25519.pub | clip.exe
ホワイ
なんか xsel
が $DISPLAY
= localhost:0.0
に接続できずに死ぬ.
どうも WSL は tty
とかディスプレイ周りの実装が変らしい(当たり前). WSL1だと DISPLAY
環境変数に $(cat /etc/resolv.conf | grep nameserver | awk '{print $2}'):0
を export
するといけたらしい(?)ので WSL 2 に実装されてないだけぽい (edit)のバージョン毎に実装が異なるぽい.
その他
同じような理由で gpg-agent
から /usr/bin/pinentry
を呼べず git
とかの PGP 署名ができない.
$ git commit -S -m "Some cool changes" error: gpg failed to sign the data fatal: failed to write commit object
解決策としては, GPG_TTY
環境変数を設定する.
$ export GPG_TTY=$(tty)
ちょっと考えたら解ることなんだけど 5 年間ぐらい詰まってたので.
メモ
自分用.
PGP キーの生成
$ gpg --full-gen-key --expert
--expert
オプションがないと暗号方式に ed25519
が選べない.
PGP 公開鍵のフィンガープリントの確認
--keyid-format
を指定しないと鍵 ID が出てこない. いつからこんなゴミ仕様になったんだ.
$ gpg --list-keys --keyid-format LONG # 出力イメージ /path/to/pubring.kbx ----------------------------- pub <Cipher>/<Public key fingerprint> <Date of creation> <Usage> [Expiry date] <Public key full fingerprint> uid <Trust> <Full name> [comment] <E-mail address> sub <Cipher/<Secret key fingerprint> <Date of creation> <Usage> [Expiry date]
ここでいう Public key fingerprint
の部分を git
に教える (keyid
のとこ).
$ git config [--global] user.signingkey <keyid>
commit
するときに -S
を付け忘れるなよな.
PGP 公開鍵の出力
$ gpg --export -a <E-mail | keyid>
で標準出力される. ペーストボードにパイプするなりファイルに出力するなりすれば良い. アドレスじゃなく keyid
で指定する方法があった気がするんだけど忘れた (edit)こともできる(というよりそのほうが一意で良い気がする).