15
12

More than 3 years have passed since last update.

gitでssh接続する際にBad configuration option: usekeychainやterminating, 1 bad configuration optionsとエラーが出たときの解決方法

Last updated at Posted at 2020-05-25

前提

・sshの公開鍵、秘密鍵を取得済み

使用する秘密鍵をconfigファイルに書く

### vimを立ち上げて~/.ssh/configを編集する。
$ vi ~/.ssh/config
-> configファイル内に下記内容を追記する。
#-------------------
Host github
  HostName github.com
  IdentityFile ~/.ssh/id_rsa
  User git
#-------------------
-> 追加後はescキー押したあとに:wqで保存します。

接続確認

こちらのコマンドで接続できているか確認できます。
$ ssh -T git@github.com

エラーの原因

私の場合は下記内容があるためにエラーになっていました。
同じ様にエラーになる場合は削除してから上記の内容を記載すると問題なく動作するかと思います。

Host *
    AddKeysToAgent yes
    UseKeychain yes

-> エラー
/home/vagrant/.ssh/config: line 3: Bad configuration option: usekeychain
/home/vagrant/.ssh/config: terminating, 1 bad configuration options

[※補足]AddKeysToAgentとUseKeychainとは何か

私の場合は削除してしまいましたが、あっても動くこともあるようなので、何をしているのか一応調べました。

AddKeysToAgentをyesにすることで、-Kオプションをつけなくてもssh-addの時やsshの時に強制的にパスフレーズがMacOSに保存されます。
また、UseKeychainをつけることで、ssh-agentを利用していなくても、MacOSに保存されたパスフレーズで自動的に~/.ssh/id_rsaなどを複合化してくれるようです。

参考

https://qiita.com/GakuNaitou/items/81dbbd3ea6211af71648
https://qiita.com/onokatio/items/397a5899a0ec16c7e60a

15
12
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
12