SSH Key连接github提示Permission denied (publickey).错误

时间:2022-04-22 10:04:10

root@debian64:/home/xiaoliuzi/.ssh/key_backup# ssh -T git@github.com

The authenticity of host 'github.com (192.30.252.131)' can't be established.

RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?yes

Warning: Permanently added 'github.com,192.30.252.131' (RSA) to the list of known hosts.

Permission denied (publickey).

解决方法:

注意先将id_rsa.pub的文件,粘贴到记事本,再添加到SSH Key中,我猜测主要原因是在粘贴过程中会有谢多余的换行或空格导致的。

下面是我在debian7下生成的SSH Key:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDP3uAi2bRNRgHxbeWdDnrVGolv9vjBRcgLpA4eq7dAEQ+525xCWYXK6Oh1XAS/i91vVNcG1xQG3K7FwJRGepOTVJtnaWRPpROV5rB6DRyy1YAuw74+iYO9bh1Xudc+eP0GTmUG58SxVVVW/GSEu+SCFtoMPwzVCtiu7N5xRlJGV0Rd4USB+WdWI/iBr+Tw9VpAzC4M6WrNNhfdTt1kiI7TKiu+WFh6IJ5YIUeZAkFFJOIFJcV67GRvgLqces+Y/tK36ZmcPCErJkJhW9pJnSfR7z2KADJSG3qbop3G79QqWXbf72q0YDC4ypAfBEizXX+QSLIIlWHVZq8fAL0734aj
qingpengliu@163.com