1
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 5 years have passed since last update.

GitHubにpush出来なくなった Permission denied(SSH key パーミッションエラー  )解決法

Last updated at Posted at 2020-01-11

AWS の構築中に本来はサーバーでの作業を、(タイムエラーに気がつかず?)
間違えてローカルで設定変更をしてしまったようで、
後に

ローカルからいつも通り git push してパーミッションエラーとなった。以下解決方法の1つを残す。####


.ssh/config
$ git push -u origin master  実行後↓パーミッショエラー内容

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

<今回の解決方法>##

GitHub にて設定済みの SSH keys に関する(つまりrsa.pemのcat/中身) rsaキーをローカルに設定し直す。
(★GitHub > settings > [SSH and GPG keys]をクリックして設定したSSHキー)

スクリーンショット 2020-01-11 23.54.24.png

①ローカルにて、 .SSH フォルダに★とペアとなる _rsa ファイルがあるのを確認。
 
②ローカルにて、 .SSH フォルダ > config に下記を記載

Host github.com
      HostName        github.com
      IdentityFile    ~/.ssh/GitHubに設定したキーと同じファイルの_rsa   ←  ここだけ各自変更
      User            git



例
Host github.com
      HostName        github.com
      IdentityFile    ~/.ssh/githubkye_rsa      
      User            git

<接続確認>

$ ssh -T git@github.co
 
  Hi 自分のgithubユーザー名! You've successfully ....

設定完了。これでpush可能。

1
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
1
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?