github 访问拒绝访问推送

标签 git github git-push

您好,我正在学习 an rails app 的初学者教程.但是我在推送存储库时遇到问题。每次我执行 git push -u 到 origin master 时,我都会遇到这个错误。

guinslym@ubuntu:~/Documents/rails_tuto/first_app$ git remote add origin https://github.com/guinslym/first_app.git
fatal: remote origin already exists.
guinslym@ubuntu:~/Documents/rails_tuto/first_app$ git push -u origin master
Warning: Permanently added the RSA host key for IP address '192.30.252.130' to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
guinslym@ubuntu:~/Documents/rails_tuto/first_app$ 

guinslym@ubuntu:~/Documents/rails_tuto/first_app$ ssh -vT git@github.com
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [192.30.252.130] port 22.
debug1: Connection established.
debug1: identity file /home/guinslym/.ssh/id_rsa type 1
debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048
debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048
debug1: identity file /home/guinslym/.ssh/id_rsa-cert type -1
debug1: identity file /home/guinslym/.ssh/id_dsa type -1
debug1: identity file /home/guinslym/.ssh/id_dsa-cert type -1
debug1: identity file /home/guinslym/.ssh/id_ecdsa type -1
debug1: identity file /home/guinslym/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1+github5
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1+github5 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: RSA 16:27[Private information I will not post it to stackoverflow]
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home/guinslym/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/guinslym/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 279
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([192.30.252.130]:22).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Remote: Forced command.
debug1: Remote: Port forwarding disabled.
debug1: Remote: X11 forwarding disabled.
debug1: Remote: Agent forwarding disabled.
debug1: Remote: Pty allocation disabled.
debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
Hi guinslym! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 2664, received 2688 bytes, in 0.1 seconds
Bytes per second: sent 21363.1, received 21555.6
debug1: Exit status 1
guinslym@ubuntu:~/Documents/rails_tuto/first_app$ 

这里我确实设置了一个私钥来使用,但是当我想要推送时我仍然有错误。我确实遵循了这个 stackoverflow answer (第一个答案)

guinslym@ubuntu:~/.ssh$ ls
id_rsa  id_rsa.pub  known_hosts
guinslym@ubuntu:~/.ssh$ ssh -i id_rsa.pub -vT git@github.com
    ...
Hi guinslym! You've successfully authenticated, but GitHub does not provide shell access.
    debug1: channel 0: free: client-session, nchannels 1
    Transferred: sent 2664, received 2688 bytes, in 0.1 seconds
    Bytes per second: sent 22659.2, received 22863.4
    debug1: Exit status 1

最佳答案

如果您需要将 ssh url 更改为远程“来源”的 http,请使用:

git remote set-url origin https://guinslym@github.com/guinslym/first_app.git

它会在 git push 上询问您的 GitHub 密码。

关于github 访问拒绝访问推送,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20964623/

相关文章:

git - 重复 `ssh-agent` 和 `ssh-add` 访问私有(private)存储库

使用非默认 SSH key 的 git clone

git - 如何将 Git 存储库的特定分支导入到另一个存储库?

git - 我如何使用 git 的 --work-tree 选项?我不断收到错误

Git 撤消别名无法正常工作

git - 复制上次提交中更改的所有文件

git - 使用 Git Bash 推送有效,但使用 Git Gui 失败

git: 为什么 "Merge branch ' master' of ...”? pull 和推时

git - 将提交从一个分支移动到另一个分支

git push origin master 给出错误权限被拒绝(github)