【】 .ssh/configのGithubの場合

数日前に、bash_profileでgithubの公開鍵を指定するのをやめた。

すると、.ssh/configにHost githubを書いているにも関わらず本日push失敗

Hostname:Project MacUser$ git push -u origin master
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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

そこで下記記事を参考に.ssh/configのHostを変更するとpush成功

https://qiita.com/shizuma/items/2b2f873a0034839e47ce

[変更前]

Host github
    HostName github.com
    Identityfile ~/.ssh/github_rsa
    Port 22
    User git

    AddKeysToAgent yes
    UseKeychain yes

[変更後]

Host github github.com
    HostName github.com
    Identityfile ~/.ssh/github_rsa
    Port 22
    User git

    AddKeysToAgent yes
    UseKeychain yes

Hostname:Project MacUser$ git push -u origin master Enumerating objects: 292, done.

Counting objects: 100% (292/292), done. Delta compression using up to 4 threads

Compressing objects: 100% (279/279), done. Writing objects: 100% (292/292), 1.23 MiB | 9.27 MiB/s, done.

Total 292 (delta 31), reused 0 (delta 0) remote: Resolving deltas: 100% (31/31), done. To github.com:(github-username)/(remote-repo).git

  • [new branch] master -> master Branch 'master' set up to track remote branch 'master' from 'origin'.

Hostname:Project MacUser$

## この現象の理由は下記記事に書いてあるようだ。

[https://kimiyuki.net/blog/2018/06/09/github-ssh-permission-denied/]