Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.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
SSH使用旧的可能缓存的用户连接到GitHub_Git_Macos_Github_Ssh_Ssh Config - Fatal编程技术网

SSH使用旧的可能缓存的用户连接到GitHub

SSH使用旧的可能缓存的用户连接到GitHub,git,macos,github,ssh,ssh-config,Git,Macos,Github,Ssh,Ssh Config,Mac OS(High Sierra)在这里。我有一个SSH密钥,example gh user,当我运行pbcopy

Mac OS(High Sierra)在这里。我有一个SSH密钥,
example gh user
,当我运行
pbcopy<~/.SSH/example gh user.pub
并将其粘贴到编辑器中时,我看到:

ssh-ed25519 <SOME_REALLY_LONG_ALPHANUM> me@example.org
到目前为止,我认为还不错

但是,当我从命令行运行以下命令时:

ssh -Tv git@github.com
有趣的是,我得到了大量的输出,结果如下:

debug1: Sending environment.
debug1: Sending env LANG = en_US.UTF-8
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi my-old-gh-user! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3452, received 2724 bytes, in 0.1 seconds
Bytes per second: sent 28403.1, received 22413.1
debug1: Exit status 1
看那个<代码>我的老gh用户!那是一个GH用户,我已经好几年没用了

SSH和/或git/GitHub想从哪里获得我的老gh用户
SSH如何缓存旧数据?如果我理解一切是如何正常工作的,
~/.ssh/config
清楚地指示ssh在作为
git
用户连接到
github.com
时使用
~/.ssh/example gh user
,对吗?我哪里出错了

如何知道当前最新的某些服务/客户端版本是什么,以及如何更新go.mod以使用它

只需
go-get-github.com/SomeExampleOrg/someservice/client
(假设原始行仍在
go.mod

这将把该存储库的
go.mod
更新为最新版本,而go.mod中关于客户端的行将显示可用的最新版本

如果该存储库是公共存储库,Go将使用正常的HTTPS URL,并且不需要您的SSH配置


TheOP在讨论中提到

ssh-Tvgit@github.com`生成以下输出:
嗨,我的老gh用户!您已成功通过身份验证,但GitHub不提供shell访问。
my old gh user
是一个多年未使用的gh老用户,必须为其配置SSH

SSH/GitHub从哪里获取my old gh用户

默认情况下,ssh将查找
~/.ssh/id\u rsa
.pub
)。如果旧的public kay注册到了旧的GitHub用户帐户SSH profile设置(as),这就解释了为什么SSH默认使用旧的GitHub帐户标识您

在新帐户中注册一个新的公钥,并确保用新密钥(或)替换默认密钥,SSH将使用新帐户对您进行身份验证

我生成了
~/.ssh/示例gh用户

然后您需要添加到
~/.ssh/config
文件中:

hostnewgh
主机名github.com
用户git
IdentityFile~/.ssh/示例gh用户
然后

ssh-Tv-newgh
cd/path/to/repo
git远程设置url源newgh:/
如何知道当前最新的某些服务/客户端版本是什么,以及如何更新go.mod以使用它

只需
go-get-github.com/SomeExampleOrg/someservice/client
(假设原始行仍在
go.mod

这将把该存储库的
go.mod
更新为最新版本,而go.mod中关于客户端的行将显示可用的最新版本

如果该存储库是公共存储库,Go将使用正常的HTTPS URL,并且不需要您的SSH配置


TheOP在讨论中提到

ssh-Tvgit@github.com`生成以下输出:
嗨,我的老gh用户!您已成功通过身份验证,但GitHub不提供shell访问。
my old gh user
是一个多年未使用的gh老用户,必须为其配置SSH

SSH/GitHub从哪里获取my old gh用户

默认情况下,ssh将查找
~/.ssh/id\u rsa
.pub
)。如果旧的public kay注册到了旧的GitHub用户帐户SSH profile设置(as),这就解释了为什么SSH默认使用旧的GitHub帐户标识您

在新帐户中注册一个新的公钥,并确保用新密钥(或)替换默认密钥,SSH将使用新帐户对您进行身份验证

我生成了
~/.ssh/示例gh用户

然后您需要添加到
~/.ssh/config
文件中:

hostnewgh
主机名github.com
用户git
IdentityFile~/.ssh/示例gh用户
然后

ssh-Tv-newgh
cd/path/to/repo
git远程设置url源newgh:/

这个有趣场景的答案在于ssh代理的工作方式和在MacOS的密钥链上缓存身份(ssh密钥)

您可以执行
ssh add-L
以获取所有当前加载的标识,其中您应该可以看到旧git ssh用户的标识

您可以使用
ssh add-D
ssh add-D
刷新标识,或使用以下方法重新加载
ssh代理

eval "$(ssh-agent -s)"
ssh-add

这个有趣场景的答案在于ssh代理的工作方式以及在MacOS的密钥链上缓存身份(ssh密钥)

您可以执行
ssh add-L
以获取所有当前加载的标识,其中您应该可以看到旧git ssh用户的标识

您可以使用
ssh add-D
ssh add-D
刷新标识,或使用以下方法重新加载
ssh代理

eval "$(ssh-agent -s)"
ssh-add

你试过这个吗?谢谢你的建议@JimB(+1)我会试试的。听起来你想让我试着运行
git-config--global-url。git@github.com代替https://github.com/
从回购根目录?只是好奇它在引擎盖下会做什么?你可以在链接的答案中看到它在“引擎盖下”做什么,它在git配置中添加了一个
而不是
条目。文档中可以找到
而不是
的完整描述,但基本上是;使用ssh而不是https.OK我运行了git config--global url。git@github.com代替https://github.com/
在repo的根目录中,然后尝试了
go build
,但我得到了完全相同的错误。知道下一步可以排除哪些故障吗?它告诉我这与Go无关,您需要修复git+ssh配置。您尝试过这个吗?感谢