こんにちわlisです!
Gitで使用するSSHアプリ(コマンド)の変更方法と、変更後に発生したエラーの対処方法です!
発生したエラーはこんな感じです。
> git clone git@bitbucket.org:xxx/proj.git Cloning into 'proj'... C:\Windows\System32\OpenSSH\ssh.exe: C:WindowsSystem32OpenSSHssh.exe: command not found fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
状況
PCを新調して、Gitの設定をしたのですが、どうにもGitHubやBitbucketからcloneできない……
と悩んでいた所
「Gitが使うOpenSSHをWindows10のものにしていたような……?」
そしてQiita記事を保存していたことを思い出しました。
GitのSSHのアプリの変更と確認
確認方法
> git config --global core.sshCommand
設定方法
> git config --global core.sshCommand <設定するアプリのパス>
初めにやったこと
こうやって設定してた
> git config --global core.sshCommand "C:\Windows\System32\OpenSSH\ssh.exe"
しかしcloneしようとすると、どうにもエラーする。
> git clone git@bitbucket.org:xxx/proj.git Cloning into 'proj'... C:\Windows\System32\OpenSSH\ssh.exe: C:WindowsSystem32OpenSSHssh.exe: command not found fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
よく見ると、なんかおかしなことになってる。
C:\Windows\System32\OpenSSH\ssh.exe: C:WindowsSystem32OpenSSHssh.exe: command not found
なんだこれ
C:WindowsSystem32OpenSSHssh.exe
解決方法
悩んだ結果、やはりおかしなパスが原因かと思い、パス指定を変えてみました。
> git config --global core.sshCommand "C:/Windows/System32/OpenSSH/ssh.exe"
「\」を「/」に変更して指定してみました。
通った!
> git clone git@bitbucket.org:xxx/proj Cloning into 'proj'... remote: Counting objects: 6, done. remote: Compressing objects: 100% (4/4), done. remote: Total 6 (delta 0), reused 0 (delta 0) Receiving objects: 100% (6/6), done.
参考
コチラを参考にしました。ありがとうございました!
あとがき
GitをWindows10のOpenSSHを使うように設定するでした!
ちゃんとメモっておかないと忘れますね……
ちょっとしたミスでのつまづきですが、わからないと時間を食ってしまうものですよね。
同じエラーが発生した方の助けになれば幸いです……!