git@github.com:权限被拒绝(公钥)[主目录存储库]

时间:2020-07-14 04:08:16

标签: git github

我正在尝试使用git管理我的dotfiles和.config目录。我创建一个新的仓库并运行git init。之后,我先运行git add .git commit -m "first commit",然后运行git remote add origin https://github.com/usename/dotfiles.git。但是,当我用git push -u origin master进行推送时,会得到:

Warning: Permanently added the RSA host key for IP address 'XXX.XX.XXX.X' to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

我不小心删除了.gitconfig(我不确定是否会导致这种情况吗?),但是我做了一个新的。

另外,当我运行git add .时,没有输出。

.gitignore

*
!.config/
.config/**
!.config/bspwm/*
!.config/compton.conf
!.config/htop/*
!.config/mpd/*
!.config/mupen64plus/*
!.config/neofetch/*
!.config/polybar/*
!.config/ranger/*
!.config/sxhkdrc/*

!.scripts/

!.bashrc
!.ncmpcpp
!.vimrc
!.xinitrc
!.Xresources

1 个答案:

答案 0 :(得分:0)

检查本地计算机的公钥:

cat ~/.ssh/id_rsa.pub

您应该看到类似这样的内容:

ssh-rsa AAAAB3NzaCsdfsd9NPghakTk54ykAmOvMwYNyVfB7P4V55wahURuYMDsQX4fEwYDBvQcJN5XFlCrH7KThL106w9yRSrPGUVI4qskm8cUKkW/GfXLIUlcKNKbCTAkldsfgsdfGl6qXZRnsr2oHcfNsl95ADGQEloPJ8h9oGW3Ji6pOz7PiXoNUxcUqsdfgsdyisSRzEB9iqSKRFCNLigeoGCHtxa7mgkBaHag+WQ5OBXmvOsmeOn8eLsMLCo6pk0cuGVAOO8J559/RophirsKuIs5+b6FVovf1dfgsdzXlmTKhU8oMIt16+srIqnUSVSThOnT3Bl21us3qL7lH username@something.local

然后复制此公钥并将其添加到github配置中。如果此答案不完整,我将编辑有关github界面的更多信息。

如果密钥在github上很麻烦,则警报将通知您您无法添加已经存在的密钥。