系统相关
首页 > 系统相关> > linux-无法推送到我的github私有存储库

linux-无法推送到我的github私有存储库

作者:互联网

在学习git时,我已经在GitHub上建立了一个私有存储库.我创建了ssh密钥并将其存储到我的GitHub帐户中,并在本地Linux机器上编辑了.ssh / config文件:

    ## github
        Host github.com
        User git
        HostName github.com
        IdentityFile ~/.ssh/github.key

我可以成功连接到我的GitHub帐户:

    $ssh -T github
    Hi <UserName>! You've successfully authenticated, but GitHub does not provide shell access.

我已经在本地计算机上初始化了一个git存储库,设置了用户并添加了一个远程存储库:

    $git init
    $git config user.name "UserName"
    $git config user.email "UserEmail"
    $git remote add origin ssh://github:<UserName?/<repositoryName>.git

我创建了一个README.md文件,将其添加到git中并提交:

    $git add README.md
    $git commit -m "First commit."

现在,每次我尝试推送时,都会出现此错误:

    $git push origin master

    ERROR: Repository not found.
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

克隆存储库是可行的,但这是我唯一能做的.

我为什么不能推送到我的私有存储库?我究竟做错了什么?

解决方法:

尝试改用scp syntax,以确保使用〜/ .ssh / config文件:

git remote set-url origin github:<username>/<repo>

然后尝试再次推动.

Git本身使用OpenSSH版本(至少一个包含Git for Windows的软件包)

> ssh -V
OpenSSH_7.5p1, OpenSSL 1.0.2k  26 Jan 2017

如“ Why doesn’t the ssh command follow RFC on URI?”中所述,它们之间存在区别:

ssh://[user@]host.xz[:port]/path/to/repo.git
vs.
user@host.xz:/path/to/repo.git

仅后者语法user@host.xz:使用ssh config file.

When SSH was originally developed, it was developed as a more secure, drop-in replacement for the earlier RSH/rlogin suite of tools.

参见“ History of the SSH protocol”.

OpenSSH(1999)早于URI(最终定稿为RFC 3986,2005年1月发布)

If the host portion was allowed to be on the form host:port, this would create a potential ambiguity: does jdoe@host.example.com:2222 refer to ~jdoe/2222 on host.example.com when connecting on the standard port, or does it refer to no file at all (or worse, ~jdoe) on host.example.com when connecting over port 2222?

标签:github,ssh,ssh-keys,linux,git
来源: https://codeday.me/bug/20191110/2014872.html