ssh 経由で fastlane match できるようにする

$ ssh my@mac.com
$ bundle exec fastlane match
...

[12:19:58]: Enter the passphrase that should be used to encrypt/decrypt your certificates
[12:19:58]: This passphrase is specific per repository and will be stored in your local keychain
[12:19:58]: Make sure to remember the password, as you'll need it when you run match on a different machine
[12:19:58]: Passphrase for Git Repo: *********
[12:20:12]: Type passphrase again: *********
security: SecKeychainAddInternetPassword <NULL>: User interaction is not allowed.
[12:20:15]: Couldn't decrypt the repo, please make sure you enter the right password!

match のパスワードは正しく入れているのになにやらエラーが出ている。ssh じゃなくて直接ログインして match は成功するので ssh 経由なのが問題っぽい。

security unlock-keychain

どうやら keychain を unlock しないといけないっぽい、 ssh 経由だと keychain にアクセスできなくなっているようだ。

下記のコマンドを実行後に fastlane match した Passphrase のところはうまくいった。

$ ssh my@mac.com
$ security unlock-keychain -p <YourPassword> ~/Library/Keychains/login.keychain

superuser.com

WARNING: fastlane requires your locale to be set to UTF-8.

しかし次のようなエラーが出た

[12:20:32]: WARNING: fastlane requires your locale to be set to UTF-8. To learn more go to https://docs.fastlane.tools/getting-started/ios/setup/#set-up-environment-variables

どうやら sshUTF-8 になってないっぽい。
ssh 接続元マシンの ssh config に UTF-8 で繋ぐように設定した。

Host *.hoge.com
  SendEnv LANG LC_ALL=en_US.UTF-8

おわり

これで万事解決。

jenkins などでビルド環境作るときはおきまりの手順っぽいけど、気軽に unlock-keychain していいものか不安である。

参考