【问题标题】:git@github.com: Permission denied (publickey) [Home directory repo] [duplicate]git@github.com:权限被拒绝(公钥)[主目录回购] [重复]
【发布时间】:2020-11-03 08:39:29
【问题描述】:

我正在尝试使用 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

【问题讨论】:

  • 您是否完全按照您输入的方式使用了这个命令? git remote add origin https://github.com/usename/dotfiles.git 你把 username 改成你的 Github 用户名了吗?你在 Github 上有一个名为 dotfiles 的现有存储库吗?
  • @sorens 是的,我刚刚删除了我的用户名。我确实有一个名为“dotfiles”的存储库,但是我删除了它并创建了一个新的。这也发生在我在我的主目录中的流浪机器中的回购中。
  • 你把你的公钥放到github了吗?
  • @sensorario 我相信我是在 vagrant 机器上做一些任务时做到的。我该如何检查?

标签: git github


【解决方案1】:

检查本地机器的公钥:

cat ~/.ssh/id_rsa.pub

您应该会看到如下内容:

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

然后复制此公钥并将其添加到 github 配置中。如果此答案不完整,我将进行编辑以获取有关 github 接口的更好信息。

如果密钥在 github 上已经存在,则会提醒您无法添加已存在的密钥。

【讨论】:

    猜你喜欢
    • 2020-01-04
    • 1970-01-01
    • 2014-03-18
    • 1970-01-01
    • 2023-01-14
    • 1970-01-01
    • 2013-11-08
    • 1970-01-01
    相关资源
    最近更新 更多