Help us understand the problem. What is going on with this article?

macOS 再起動で GitHub と SSH 接続できなくなる【Sourcetree】

More than 1 year has passed since last update.

はじめに

結論としては Sourcetree 側の不具合だと思われます。単純な不具合回避方法としてご覧ください。
(Sourcetree を批判するものではありません)

環境と現象

環境:
- macOS Sierra 10.12.6
- Sourcetree 2.6.3
- brew cask でインストール
- GitHub、Bitbucket で確認
- Sourcetree 側に GitHub アカウントを登録
- Sourcetree 側で SSH 鍵を作成 & GitHub 登録

現象:
macOS を再起動すると SSH で GitHub 等にアクセスできなくなる
* Permission denied (publickey). と言われる
* Sourcetree 経由でも コマンド経由でも同様

原因と対策

原因は Sourcetree 側で ~/.ssh/config に自動追加される設定です。

~/.ssh/config
# --- Sourcetree Generated ---
Host AkkeyLab-GitHub
    HostName github.com
    User AkkeyLab
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/AkkeyLab-GitHub
    UseKeychain yes
    AddKeysToAgent yes
# ----------------------------

User の項目が GitHub アカウントのものになっていますが、 git にしてあげなければなりません。
したがって、以下のように変更することで再起動しても SSH 接続ができるようになります。

~/.ssh/config
# --- Sourcetree 修正版 -------
Host AkkeyLab-GitHub
    HostName github.com
    User git
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/AkkeyLab-GitHub
    UseKeychain yes
    AddKeysToAgent yes
# ----------------------------
planningdev
九州工業大学 ITサービス開発・運用団体
https://www.planningdev.com/
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした