環境
- Windows 10
- Git 2.8.1
現象
Git Bash を起動するたびにssh-add key
を実行しないと、Remoteにアクセスするコマンド(git pull
など)を実行できない。
キーを登録しないと、以下のように怒られる。
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
原因
- 登録している ssh キーの名称がデフォルト(id_rsa)ではない1
対策
/etc/ssh/ssh_config
にキーを指定してやる
設定手順
- 普通にGit Bashを立ち上げる
- タスクバー上のアイコンを
Ctrl-Shift-Click
する(管理者権限でGit Bashが立ち上がる)2 vim /etc/ssh/ssh_config
- 以下を追記する
Host bitbucket.org
HostName bitbucket.org
User git
Port 22
IdentityFile ~/.ssh/my_rsa
これは、↓と等価とのこと1
ssh git@bitbucket.org -p 22 -i ~/.ssh/my_rsa
-
問題の原因および対策 [メンチカツには醤油でしょ!!] ↩
-
Git Bashを管理者権限で実行する方法 [@YamasakiKenta] ↩