0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

git cloneの時に鍵がないと怒られた時の対処法

Last updated at Posted at 2019-12-04

git cloneの時に鍵がないと怒られた時の対処法

先日とあるプライベートレポジトリをcloneしたのですがこのようなエラーメッセージが出て失敗してしまいました。

git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

鍵がないよと言われてそうなので鍵を生成してgithubにアップロードします。

shell
$ ssh-keygen -t rsa -C "githubに登録してあるメールアドレス"

で鍵を生成した後~/.ssh/に生成されるid_rsa.pubというファイルをgithubにアップロードします。
gitへのアップロードは
https://github.com/settings/keys
から行います。

その後~/.ssh/configに

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

と書き込めばcloneできるようになります。

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?