git github访问拒绝访问推送
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20964623/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
github access denied access for push
提问by Papouche Guinslyzinho
Hi I'm following a beginner tutorial for an rails app. But I'm having an issue with pushing the repository. Each time I'm doing and git push -u to origin master I'm having this error.
嗨,我正在学习Rails 应用程序的初学者教程。但是我在推送存储库时遇到了问题。每次我做和 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 [email protected]
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 [email protected]
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 [email protected] 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$
Here I did setup an private key to use but I'm still having error when I want to push. I did follow this stackoverflow answer(the first answer)
在这里,我确实设置了一个要使用的私钥,但是当我想推送时仍然出错。我确实遵循了这个stackoverflow 答案(第一个答案)
guinslym@ubuntu:~/.ssh$ ls
id_rsa id_rsa.pub known_hosts
guinslym@ubuntu:~/.ssh$ ssh -i id_rsa.pub -vT [email protected]
...
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
回答by VonC
If you need to change your ssh url by an http one for your remote 'origin', use:
如果您需要通过 http 更改远程“来源”的 ssh url,请使用:
git remote set-url origin https://[email protected]/guinslym/first_app.git
It will ask for your GitHub password on the git push
.
它会在git push
.
回答by Iwan Aucamp
A possible cause is that you are sshing in to the box your trying to push from and you have agent forwarding enabled.
一个可能的原因是您正在尝试推送到框,并且您启用了代理转发。
E.g:
例如:
user@box-a:~ ssh box-b
user@box-b:~ git -C path/to/repo push
Access denied.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
In this case it would be trying to use keys from box-a to authenticate. Solutions are:
在这种情况下,它将尝试使用 box-a 中的密钥进行身份验证。解决办法是:
- Add key from box-a to github
- Disable agent forwarding on box-a
- 将 box-a 中的密钥添加到 github
- 在 box-a 上禁用代理转发
To disable agent forwarding, add this to your ~/.ssh/config
file:
要禁用代理转发,请将其添加到您的~/.ssh/config
文件中:
Host *github.com
ForwardAgent no