LoginSignup
0
0

(Windowsユーザー用メモ)gitでPlease make sure you have the correct access rights and the repository exists. が出た時の対処法

Last updated at Posted at 2024-04-24

記事の内容

この記事がLinux用に書かれた記事だったため,Windowsユーザー用にメモを残しておく.詳しい内容は上記記事を確認してください!

エラー内容

Bad owner or permissions on ~/.ssh/config
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

解決方法

具体的な手順

➀ sshKeyの再発行
➁ githubに公開鍵を登録
➂ 使用する秘密鍵をconfigファイルに設定

➀ sshKeyの再発行

sshKeyを作成する。 (hoge以降はgithubに登録しているメアド)

$ ssh-keygen -t rsa -C hoge@example.com

以下の3つが聞かれるが「すべてEnter」でOK

Enter file in which to save the key (~/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter passphrase (empty for no passphrase):

sshKeyが発行されたか確認

$ dir ~/.ssh

以下の2つが表示されればOK

id_rsa
id_rsa.pub

➁githubに公開鍵を登録

Githubにログインして、右上の自分のアイコンをクリック, Settings > SSH and GPG keys > New SSH keys をクリックします。

Titleの欄に何に使う為なのか、わかるように名前をつけてあげます。(会社用Macbookとか、AWS cloud9 とか)

★公開鍵をコピー

以下のコマンドを実行して公開鍵を表示

$ Get-Content ~/.ssh/id_rsa.pub

以下のように公開鍵が表示される

ssh-rsa hogehogehogehoge...~~略~~...hogehoge  mail@example.com

「ssh-rsa」~「mailの前まで」をコピー
→ Githubに戻り、Keyの部分にコピーした内容をペーストして、Add SSH Keyをクリックすれば、Githubに公開鍵を登録できます。

➂使用する秘密鍵をconfigファイルに設定

まずconfigファイルを開く.
以下は,メモ帳を使って開く.

$ notepad.exe ~/.ssh/config

vscodeがインストール済みなら以下

$ code ~/.ssh/config

configファイル開いたら,以下をコピー&ペースト

Host github
  HostName github.com
  IdentityFile ~/.ssh/id_rsa
  User git

完了!

参考文献

gitでPlease make sure you have the correct access rights and the repository exists. が出た時の対処法

0
0
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
0
0