2025-04-03に デスクトップ版BitwardenをSSHエージェントとして使用してローカルに秘密鍵を保持せずサーバーログインやGit pushするという記事を書いたが、そこで記載したバグが Flatpak版(2025.3.0) で修正されているか、確認した。
バージョン 2025.3.0
SDK 'main (50f5a17)'
Shell 34.0.0
Renderer 132.0.6834.83
Node 20.18.1
Architecture x64
そして、折角なのでChromeOS Flexで試してみた。端末は Surface Pro 3のIntel Core i5、メモリ4GB、ストレージ126GB。
ということで、
Flatpakをインストールする。以前1は、仮想マシンコンテナ関係のコマンドvmc
を打つ手順があったが、もう不要だ。
Flatpak—the future of application distributionにあるとおりsudo apt install flatpak
するだけである。
$ sudo apt install flatpak
$ flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
$ flatpak install flathub com.bitwarden.desktop
flatpak run com.bitwarden.desktop
で起動する。インストすれば、検索メニューからのアプリ起動できる。
そして、Flatpak
の権限設定を変更するために
Flatsealもインストールする。flatpak install flathub com.github.tchx84.Flatseal
を実行する。
そして、以前、紹介したように以下のとおり設定する。
- Socket:: Secure Shell agent : socket=ssh-auth = ON
- Filesystem:: Other files :
~/.var/app/com.bitwarden.desktop/data/
環境変数BITWARDEN_SSH_AUTH_SOCK
の設定は、
githubのissueのコメントとおりする必要はなかった。
$ ls ~/.var/app/com.bitwarden.desktop/data/
.bitwarden-ssh-agent.sock
$ export SSH_AUTH_SOCK=/home/arimasou16/.var/app/com.bitwarden.desktop/data/.bitwarden-ssh-agent.sock
$ ssh-add -L
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIN9pPLbplfC+0VjkO/2Ou5050jdkVZvEJPxCDrh237YI github
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMoffy1EeJZxToXMSQe8/MxDmQ+kP8E6Ey4LKVd9qXG+ ubuntu server
ちゃんと機能しているっぽい。が、
$ ssh git@github.com
The authenticity of host 'github.com (20.27.177.113)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
sign_and_send_pubkey: signing failed for ED25519 "github" from agent: agent refused operation
git@github.com: Permission denied (publickey).
とエラー。/home/arimasou16/.ssh/config
を作成したり、/home/arimasou16/.ssh/known_hosts
の権限を変更したりするも駄目。というか
arimasou16@penguin:~$ ls -l ~/.ssh
ls: cannot access '/home/arimasou16/.ssh/config': Permission denied
ls: cannot access '/home/arimasou16/.ssh/known_hosts': Permission denied
total 0
-????????? ? ? ? ? ? config
-????????? ? ? ? ? ? known_hosts
なにか権限とかユーザ名が文字化けしている。はてな?と思って調べると
Chromebook で SSH を使用してリモート サーバーに接続するの記事のとおり、~/.ssh/config
と~/.ssh/known_hosts
の設定画面が用意されている。

これはもちろん、ここで秘密鍵などを設定すればちゃんとログインできる。しかし、秘密鍵をインポートせずだとBitwardenは反応せずエラー終了してしまう。ふうむ、逆にChromebookだとBitwardenでのSSHエージェントとして使用は難しいのか…
と諦めかけたが、普通にssh user@192.168.0.1 -p 22
と打ちAre you sure you want to cotinue connecting (yes/no/[fingerprint])?
でyes
と回答する。すると、Failed to add the host to the list of known hosts (/home/arimasou16/.ssh/known_hosts).
と表示されるが、Bitwardenに切り替えると、通常どおり認可するかダイアログが表示されているので、認可ボタンを押せば、ログインできる。これはgit
コマンドでも同じ。

これでChromebookからサーバーに繋ぐときやgit
を使うときもいちいち秘密鍵をダウンロードしなくて済む。Flatpak版もちゃんと機能して、クリップボードからのインポートも正常に出来ていた。めでたし、めでたし。