我在使用两个不同的SSH密钥/ GitHub帐户以便一起玩时遇到一些麻烦.我有以下设置:
Repos可从一个帐户使用 git@github.com:accountname
Repos可从其他帐户使用 git@github.com:anotheraccount
每个帐户都有自己的SSH密钥.已添加两个SSH密钥,我已创建配置文件.我不相信配置文件是正确的.我不太确定如何指定使用的repos git@github.com:accountname应该使用id_rsa并且git@github.com:anotheraccount应该使用id_rsa_anotheraccount.
我创建了两个独立的 GitHub 帐户。
我还使用同一设备为它们生成了两个单独的 SSH 密钥。
当我git config user.name在终端中输入时,输出显示USERNAME2。
我现在想在帐户 1 中工作,因此我输入git config --global user.name "USERNAME1并为电子邮件执行了相同的操作。
但我认为它并没有真正切换帐户,只是重命名了我的用户名什么的?我认为这是因为当我尝试在帐户中创建新的存储库时,对于所有 git 命令,我不断收到错误fatal: not a git repository (or any of the parent directories): .git,这是我以前在运行单个帐户时从未遇到过的错误。
我的 SSH 密钥位于两个不同的文件夹中(对于 account1,它位于主目录中的 .ssh 中,对于 account2,它位于主目录中的 .newssh 文件夹中)。
我该怎么办?
我正在使用MAC OS Yosemite,我想将一个17 MB的文件推送到我的github-Account。我在ssh和https上都尝试了git,但都没有用。
GIT_TRACE=1 GIT_CURL_VERBOSE=1 git push -u origin master返回最后6行:
Counting objects: 243, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (118/118), done.
packet_write_wait: Connection to 192.30.253.113 port 22: Broken pipe
fatal: The remote end hung up unexpectedly
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)
在寻找解决方案时,我开始在各种配置脚本中设置TCPKeepAlive,ServerAlive,ClientAlive参数,最后以~/.ssh/config:
Host github.com
PubKeyAuthentication yes
IdentityFile ~/.ssh/id_rsa.pub
ServerAliveInterval 300
TCPKeepAlive no
#ServerAliveCountMax 2400
Run Code Online (Sandbox Code Playgroud)
在/etc/sshd_config:
# $OpenBSD: sshd_config,v 1.89 2013/02/06 00:20:42 dtucker Exp $
# This is …Run Code Online (Sandbox Code Playgroud) github ×3
ssh ×2
command-line ×1
git ×1
git-push ×1
https ×1
ssh-keys ×1
windows-subsystem-for-linux ×1
wsl-2 ×1