Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
&引用;拒绝许可(公钥)。”;Git错误_Git_Github_Ssh - Fatal编程技术网

&引用;拒绝许可(公钥)。”;Git错误

&引用;拒绝许可(公钥)。”;Git错误,git,github,ssh,Git,Github,Ssh,我已经在github上注册了我的机器的ssh密钥,并通过键入ssh来验证它是否有效git@github.com并收到一个指示身份验证成功的响应 然而,当我尝试将机器上的源代码推送到git存储库时,我收到了 Permission denied (publickey). fatal: The remote end hung up unexpectedly 我已经研究过与我有相同问题的其他线程,它们似乎都建议向github注册ssh密钥,我已经这样做了 编辑:我的工作站上my.git/config文

我已经在github上注册了我的机器的ssh密钥,并通过键入
ssh来验证它是否有效git@github.com
并收到一个指示身份验证成功的响应

然而,当我尝试将机器上的源代码推送到git存储库时,我收到了

Permission denied (publickey).
fatal: The remote end hung up unexpectedly
我已经研究过与我有相同问题的其他线程,它们似乎都建议向github注册ssh密钥,我已经这样做了

编辑:我的工作站上my.git/config文件的内容

[core]  
    repositoryformatversion = 0
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = ssh://github.com/OSU-Net/list_expiration
[branch "master"]
    remote = origin
    merge = refs/heads/master

有什么想法吗?

遥控器的
url
行似乎缺少用户名。您获得的权限被拒绝的原因是SSH默认为您的本地系统用户名,因为未指定任何用户名。除非您的本地用户名恰好与远程用户名相同,否则它将拒绝登录,因为您的公钥与该名称的帐户没有关联

远程URL的格式应为
ssh://@/path/to/git/repo/
,对于Github,则为
git@github.com:/.git

您可以使用以下命令更改源url:

git remote set-url origin git@github.com:OSU-Net/list_expiration.git

你加了遥控器吗?键入git remote-v
Yes时会看到什么。它们都指向我的github存储库源的urlssh://github.com/my_repository_dir (取回)来源ssh://github.com/my_repository_dir (推)