To build git code management warehouse, ssh-key does not have permission, prompting’ Permission denied (publickey).’

  git, question
The key's randomart image is:
 +---[RSA 2048]----+
 |    .+Bo+oo      |
 |     +o*oo       |
 |    o +*o      . |
 |     oo...   .+.+|
 |       .S.  +oo=+|
 |        o  E .o++|
 |         . o.o.++|
 |          o *o*. |
 |           o *o  |
 +----[SHA256]-----+
 DDYSdeMacBook-Pro:.ssh root# ls
 id_rsa        id_rsa.pub
 DDYSdeMacBook-Pro:.ssh root# pbcopy < ~/.ssh/id_rsa.pub
 DDYSdeMacBook-Pro:.ssh root# ssh -T  git@jjys168.com
 ssh: connect to host  jjys168.com port 22: Connection refused
 DDYSdeMacBook-Pro:.ssh root# ssh -T  git@git.jjys168.com
 The authenticity of host 'git.jjys168.com (10.0.17.248)' can't be established.
 ECDSA key fingerprint is SHA256:+DTw/FsJ0q+UOCsohhrUKCVhpVJuaYSITVpcZ8+aH3o.
 Are you sure you want to continue connecting (yes/no)?  yes
 Warning: Permanently added 'git.jjys168.com,10.0.17.248' (ECDSA) to the list of known hosts.
 Permission denied (publickey).

According to Daniel’s technology blog routine, step by step, the result still failed. I could do it from github, and then the architect of git also said it was helpless, because they were all windows desktop computers, but mine was Apple. …

After searching a lot of information, I said that if you re-create the key or restart it, it will still fail.
I’ve come to post to ask Youmuyou, a big boss who has encountered similar situations.

Try the profile

Add the following code snippet to the new. ssh/config file:

Host git.xxx.net//Domain Name or IP
 User  xxxx@email.com
 PreferredAuthentications publickey
 Identity file ~/.ssh/coding _ RSA//public key repository for non-default addresses generated

For example, my Github configuration

# Github
 Host  github.com
 User  xxxx@gmail.com
 PreferredAuthentications publickey
 IdentityFile ~/.ssh/id_rsa