有馬総一郎のブログ

(彼氏の事情)

2026年04月09日 06:37:59 JST - 2 minute read - Linux

SeaDrive-Cliを二要素認証環境で使う

ディスク容量が少なめなChromebookでは、仮想ドライブSeaDriveを使いたい。また、ChromebookのLinuxコンテナでインストール・起動したアプリは、トレイアイコン化などが出来ない(難しい?)という事情もあり、CLI版を利用することにした。

Drive Client for Linux - Seafile User Manual にインストール手順は記載されているが、二要素認証(2FA)を使用しているケースについては書かれていなかったため、自分用としてメモしておく。

トークン取得

結論から言うと、APIリクエスト時のヘッダに認証コード(TOTP)として -H "X-SEAFILE-OTP:123456" を付与すれば良い。

具体的には以下のように curl コマンドを実行する。

curl -d "username=username@example.com" -d "password=PASSWORD" -H "X-SEAFILE-OTP:123456" https://seafile.example.com/api2/auth-token/

成功すると、以下のようにトークン値が返ってくる。

{"token":"1234567890abcdefghijklmnopqrstuvwxyzABCD"}

インストール・前準備

ダウンロードしたAppImageに実行権限を付与し、パスの通ったディレクトリへ配置。必要なディレクトリも作成しておく。

chmod +x SeaDrive-cli-x86_64-3.0.18.AppImage
mv SeaDrive-cli-x86_64-3.0.18.AppImage seadrive-cli
sudo cp seadrive-cli /usr/local/bin/
mkdir ~/SeaDrive
mkdir -p ~/.config/systemd/user

設定ファイル作成

設定ファイルは公式ドキュメントの通りで問題ない。取得したトークンを記載する。

~/.seadrive/seadrive.conf

[account]
server = https://seafile.example.com
username = username@example.com
token = 1234567890abcdefghijklmnopqrstuvwxyzABCD
is_pro = false

[general]
client_name = chromebook

[cache]
size_limit = 10GB
clean_cache_interval = 10

自動起動・停止設定

Chromebookの場合、~/.sommelierrc~/.config/autostart/ 内の .desktop ファイルでの自動起動は制御が難しいため、systemdを使ってユーザーレベルで自動起動・停止を行う。

~/.config/systemd/user/seadrive.service

[Unit]
Description=SeaDrive Client
After=network.target

[Service]
Type=simple
ExecStart=/usr/local/bin/seadrive-cli -c %h/.seadrive/seadrive.conf -f -d %h/.seadrive/data -l %h/.seadrive/logs/seadrive.log %h/SeaDrive
ExecStop=/usr/bin/fusermount -u %h/SeaDrive
Restart=on-failure
RestartSec=5

[Install]
WantedBy=default.target

最後にsystemdのデーモンをリロードし、サービスの有効化と起動、ステータス確認を行う。

systemctl --user daemon-reload
systemctl --user enable seadrive.service
systemctl --user start seadrive.service
systemctl --user status seadrive.service 

これで良し。