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



我正在尝试用git管理我的dotfiles和.config目录。我创建了一个新的repo并运行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

检查本地机器的公钥:

cat ~/.ssh/id_rsa.pub

你应该看到这样的东西:

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

然后复制这个公钥并将其添加到github配置中。如果这个答案不完整,我会编辑更好的信息关于github接口。

如果密钥在github上已经存在,则会有一个警告通知您无法添加已经存在的密钥。

最新更新