Can';尽管在代理中添加了标识,但无法使用SourceTree推送到github:权限被拒绝(公钥)

Can';尽管在代理中添加了标识,但无法使用SourceTree推送到github:权限被拒绝(公钥),github,atlassian-sourcetree,ssh-keys,Github,Atlassian Sourcetree,Ssh Keys,如果我运行ssh add-l,我会像预期的那样在列表中看到我的身份。如果我运行ssh-vTgit@github.com我得到以下输出: OpenSSH_7.9p1, LibreSSL 2.7.3 debug1: Reading configuration data /Users/myself/.ssh/config debug1: Reading configuration data /etc/ssh/ssh_config debug1: /etc/ssh/ssh_config line 48:

如果我运行
ssh add-l
,我会像预期的那样在列表中看到我的身份。如果我运行
ssh-vTgit@github.com
我得到以下输出:

OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /Users/myself/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to github.com [140.82.113.4] port 22.
debug1: Connection established.
debug1: identity file /Users/myself/.ssh/id_rsa type -1
debug1: identity file /Users/myself/.ssh/id_rsa-cert type -1
debug1: identity file /Users/myself/.ssh/id_dsa type -1
debug1: identity file /Users/myself/.ssh/id_dsa-cert type -1
debug1: identity file /Users/myself/.ssh/id_ecdsa type -1
debug1: identity file /Users/myself/.ssh/id_ecdsa-cert type -1
debug1: identity file /Users/myself/.ssh/id_ed25519 type -1
debug1: identity file /Users/myself/.ssh/id_ed25519-cert type -1
debug1: identity file /Users/myself/.ssh/id_xmss type -1
debug1: identity file /Users/myself/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version babeld-849b9b5f
debug1: no match: babeld-849b9b5f
debug1: Authenticating to github.com:22 as 'git'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: rsa-sha2-512
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ssh-rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /Users/myself/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: Generated by Sourcetree on macOS for myself-GitHub RSA SHA256:WnUQPEasG3tUVyEkE7Ufo9fGoRqCdUeY9ohZ7OU6fsc agent
debug1: Will attempt key: /Users/myself/.ssh/id_rsa
debug1: Will attempt key: /Users/myself/.ssh/id_dsa
debug1: Will attempt key: /Users/myself/.ssh/id_ecdsa
debug1: Will attempt key: /Users/myself/.ssh/id_ed25519
debug1: Will attempt key: /Users/myself/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-rsa,rsa-sha2-512,rsa-sha2-256,ssh-dss>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: Generated by Sourcetree on macOS for myself-GitHub RSA SHA256:WnUQPEasG3tUVyEkE7Ufo9fGoRqCdUeY9ohZ7OU6fsc agent
debug1: Server accepts key: Generated by Sourcetree on macOS for myself-GitHub RSA SHA256:WnUQPEasG3tUVyEkE7Ufo9fGoRqCdUeY9ohZ7OU6fsc agent
debug1: Authentication succeeded (publickey).
Authenticated to github.com ([140.82.113.4]:22).
debug1: channel 0: new [client-session]
debug1: Entering interactive session.
debug1: pledge: network
debug1: Sending environment.
debug1: Sending env LC_TERMINAL_VERSION = 3.3.8
debug1: Sending env LANG = en_US.UTF-8
debug1: Sending env LC_TERMINAL = iTerm2
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi myself! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3564, received 2484 bytes, in 0.2 seconds
Bytes per second: sent 18846.5, received 13135.4
debug1: Exit status 1
OpenSSH_7.9p1,LibreSSL 2.7.3 debug1:正在读取配置数据/Users/imf/.ssh/config debug1:读取配置数据/etc/ssh/ssh\u config debug1:/etc/ssh/ssh_config第48行:应用* debug1:连接到github.com[140.82.113.4]端口22。 debug1:已建立连接。 debug1:identity file/Users/imf/.ssh/id\u rsa type-1 debug1:identity file/Users/imf/.ssh/id_rsa-cert type-1 debug1:identity file/Users/imf/.ssh/id_dsa type-1 debug1:identity file/Users/imf/.ssh/id_dsa-cert type-1 debug1:identity file/Users/imf/.ssh/id_ecdsa type-1 debug1:identity file/Users/imf/.ssh/id_ecdsa-cert type-1 debug1:identity file/Users/imf/.ssh/id_ed25519 type-1 debug1:identity file/Users/imf/.ssh/id_ed25519-cert type-1 debug1:identity file/Users/imf/.ssh/id_xmss type-1 debug1:identity file/Users/imf/.ssh/id_xmss-cert type-1 debug1:本地版本字符串SSH-2.0-OpenSSH_7.9 调试1:远程协议版本2.0,远程软件版本babeld-849b9b5f debug1:不匹配:babeld-849b9b5f debug1:正在以“git”身份向github.com:22进行身份验证 debug1:SSH2\u MSG\u KEXINIT已发送 debug1:SSH2\u MSG\u KEXINIT已收到 debug1:kex:算法:curve25519-sha256 debug1:kex:主机密钥算法:rsa-sha2-512 debug1:kex:server->client cipher:chachacha20-poly1305@openssh.comMAC:压缩:无 debug1:kex:client->server cipher:chachacha20-poly1305@openssh.comMAC:压缩:无 debug1:需要SSH2\u MSG\u KEX\u ECDH\u回复 debug1:服务器主机密钥:ssh rsa SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 debug1:主机“github.com”已知并与RSA主机密钥匹配。 debug1:在/Users/imf/.ssh/known_hosts中找到密钥:1 debug1:在134217728块之后重新键入 debug1:SSH2\u MSG\u已发送新密钥 debug1:应为SSH2\u MSG\u NEWKEYS debug1:SSH2\u MSG\u接收到新密钥 debug1:在134217728块之后重新键入 debug1:将尝试密钥:由macOS上的Sourcetree为自己生成GitHub RSA SHA256:WnUQPEasG3tUVyEkE7Ufo9fGoRqCdUeY9ohZ7OU6fsc代理 debug1:将尝试密钥:/Users/imf/.ssh/id\u rsa debug1:将尝试密钥:/Users/imf/.ssh/id\u dsa debug1:将尝试密钥:/Users/imf/.ssh/id\u ecdsa debug1:将尝试密钥:/Users/imf/.ssh/id_ed25519 debug1:将尝试密钥:/Users/imf/.ssh/id\u xmss debug1:SSH2\u MSG\u EXT\u接收到信息 debug1:kex_输入_外部_信息:服务器信号algs= debug1:SSH2\u消息\u服务\u接收 debug1:可以继续的身份验证:公钥 debug1:下一个身份验证方法:公钥 debug1:提供公钥:由macOS上的Sourcetree为自己生成GitHub RSA SHA256:WnUQPEasG3tUVyEkE7Ufo9fGoRqCdUeY9ohZ7OU6fsc代理 debug1:服务器接受macOS上的Sourcetree为自己生成的密钥GitHub RSA SHA256:WnUQPEasG3tUVyEkE7Ufo9fGoRqCdUeY9ohZ7OU6fsc代理 debug1:身份验证成功(公钥)。 通过github.com的身份验证([140.82.113.4]:22)。 调试1:通道0:新建[客户端会话] debug1:进入交互式会话。 debug1:保证:网络 debug1:发送环境。 debug1:发送环境LC_终端_版本=3.3.8 debug1:发送env LANG=en_US.UTF-8 debug1:发送环境LC_终端=iTerm2 调试1:客户端输入通道请求:通道0 rtype退出状态回复0 嗨,我自己!您已成功通过身份验证,但GitHub不提供shell访问。 调试1:通道0:空闲:客户端会话,nchannels 1 已传输:0.2秒内发送3564字节,接收2484字节 每秒字节数:发送18846.5,接收13135.4 debug1:退出状态1 我仍然无法将代码推送到github,尽管在这个调试输出中获得了
您已经成功地验证了
消息,SSH标识由SourceTree本身生成,并且通过执行
eval“$(SSH代理)”
来确保我的SSH代理正在运行

我还可以在github配置文件中看到所需的密钥

这里怎么了

我的SSH代理正在通过执行eval“$(SSH代理)”运行

这可能就是问题所在
ssh
知道如何通过
ssh\u AUTH\u SOCK
环境变量与
ssh代理进行对话。环境变量仅对进程及其子进程可见

eval“$(ssh代理)”
仅为此shell及其子代设置
ssh\u AUTH\u SOCK
;这就是你从那壳里逃出来的东西。如果在这个shell中运行
git
,它应该可以工作。但是,如果您有一些独立程序不是从这个shell启动的,比如Atlassian Sourcetree,当它运行ssh时,它将不知道如何与该ssh代理通信

您可以从该shell启动Sourcetree,但这不是一个很好的解决方案


要解决此问题以及许多其他ssh相关问题,请在登录时启动ssh代理。这应该由您的操作系统为您完成,如果没有,请遵循操作系统的说明。否则,,.

你能用普通的
git
推送吗?这已经在我的
~/.ssh/config
中完成了,这就是它在Mac上的工作方式,但在我的电脑上不起作用:
使用keychain yes addkeystagent yes
我还关闭了控制台,并检查了ssh代理是否在新的控制台中运行,它是:
SSH\u AUTH\u SOCK=/var/folders/22/qj9h4nwj45v60hqxmj43f18c000gq/T//SSH-nNGJpsrkl3od/agent.46805;导出SSH_AUTH_SOCK;SSH_AGENT_PID=46806;导出SSH\u代理\u PID;回声剂pid 46806
正在运行
打开-控制台中的SourceTree
也不允许打开的结果SourceTree使用该代理。@eComEvo听起来好像您的ssh代理正在工作。这有用吗
ssh-add-K/path/of/private/key这次起作用了。为什么在我调试这个问题时,它在其他20次尝试时都不起作用,这对我来说是个谜-/