当前位置: 首页 > news >正文

邵阳相亲网站网站建设报价方案

邵阳相亲网站,网站建设报价方案,做网站沈阳,低代码开发平台是什么文章目录 使用多个 GitHub 账号的 SSH 配置与常见问题排查摘要目录1. 使用多个 GitHub 账号的场景介绍2. 配置多个 SSH 密钥2.1 生成多个 SSH 密钥2.2 添加 SSH 密钥到 SSH 代理2.3 将 SSH 公钥添加到 GitHub 账户 3. 配置 SSH 代理与 GitHub 账户的关联3.1 为不同仓库设置不同…

文章目录

      • 使用多个 GitHub 账号的 SSH 配置与常见问题排查
        • 摘要
        • 目录
        • 1. 使用多个 GitHub 账号的场景介绍
        • 2. 配置多个 SSH 密钥
          • 2.1 生成多个 SSH 密钥
          • 2.2 添加 SSH 密钥到 SSH 代理
          • 2.3 将 SSH 公钥添加到 GitHub 账户
        • 3. 配置 SSH 代理与 GitHub 账户的关联
          • 3.1 为不同仓库设置不同的 GitHub 账号
        • 4. SSH 连接 GitHub 时常见错误排查
          • 4.1 问题 1:`Connection closed by 198.18.0.35 port 22`
          • 4.2 问题 2:`Permission denied (publickey)`
          • 4.3 问题 3:`Host key verification failed`
        • 5. 总结

使用多个 GitHub 账号的 SSH 配置与常见问题排查

摘要

在开发过程中,可能会涉及到多个 GitHub 账号的使用。为了避免每次切换账号时手动输入用户名和密码,我们可以通过配置多个 SSH 密钥来管理这些账号。本文将详细介绍如何为每个 GitHub 账号生成独立的 SSH 密钥、如何配置 SSH 代理、以及在使用 SSH 连接克隆仓库时遇到的常见错误及其解决方案。


目录
  1. 使用多个 GitHub 账号的场景介绍
  2. 配置多个 SSH 密钥
  3. 配置 SSH 代理与 GitHub 账户的关联
  4. SSH 连接 GitHub 时常见错误排查
  5. 总结

1. 使用多个 GitHub 账号的场景介绍

在日常开发中,可能有以下场景需要使用多个 GitHub 账号:

  • 工作与个人项目分离:你可能有一个工作账号用于公司项目管理,还有一个个人账号用于自己的开源项目或其他私有项目管理。
  • 多重身份管理:不同的组织或团队可能要求你使用不同的 GitHub 账号来管理项目。

为了简化这些场景中的账户切换和管理,我们可以通过 SSH 配置,让每个仓库使用特定的 GitHub 账号而无需反复输入密码或切换登录状态。


2. 配置多个 SSH 密钥
2.1 生成多个 SSH 密钥

每个 GitHub 账号需要一个独立的 SSH 密钥。通过 ssh-keygen 命令为每个账号生成密钥,并指定不同的文件名。

为第一个 GitHub 账号生成密钥:

ssh-keygen -t rsa -b 4096 -C "your-email-for-account1@example.com"

命令执行后,它会提示你输入文件名,保存路径可以为:

/home/your-username/.ssh/id_rsa_account1

同样,为第二个账号生成另一个密钥:

ssh-keygen -t rsa -b 4096 -C "your-email-for-account2@example.com"

保存路径可以为:

/home/your-username/.ssh/id_rsa_account2
2.2 添加 SSH 密钥到 SSH 代理

接下来,需要启动 SSH 代理并将生成的密钥添加到代理中。

启动 SSH 代理:

eval "$(ssh-agent -s)"

然后将每个密钥添加到代理中:

ssh-add ~/.ssh/id_rsa_account1
ssh-add ~/.ssh/id_rsa_account2
2.3 将 SSH 公钥添加到 GitHub 账户

在 GitHub 网站上,将每个公钥分别添加到对应的 GitHub 账户中。

  1. 打开终端并查看公钥内容:
cat ~/.ssh/id_rsa_account1.pub
  1. 将显示的内容复制,然后登录到第一个 GitHub 账号:

    • 进入 Settings -> SSH and GPG keys
    • 点击 New SSH key,粘贴公钥并保存。
  2. 对第二个账号执行相同的操作,将 ~/.ssh/id_rsa_account2.pub 添加到 GitHub。


3. 配置 SSH 代理与 GitHub 账户的关联

为了让 Git 在克隆和操作时能够正确选择相应的 SSH 密钥,我们需要通过 SSH 配置文件(~/.ssh/config)来为每个 GitHub 账号设置特定的 Host

编辑 ~/.ssh/config 文件,添加以下内容:

# Account 1
Host github-account1HostName github.comUser gitIdentityFile ~/.ssh/id_rsa_account1# Account 2
Host github-account2HostName github.comUser gitIdentityFile ~/.ssh/id_rsa_account2

这样,Git 在访问 github-account1github-account2 时,会使用相应的密钥进行身份验证。

3.1 为不同仓库设置不同的 GitHub 账号

在克隆仓库时,指定相应的 Host 名称。例如,克隆第一个账户下的仓库时:

git clone git@github-account1:username/repo.git

对于第二个账户:

git clone git@github-account2:username/repo.git

通过这种方式,你可以轻松管理多个 GitHub 账号,避免反复输入用户名和密码。


【注意⚠️】:

  • 上述使用的是:git@github-account1 和 git@github-account2。而不是 github.com;
  • 不能使用 github.com,要使用在 config 文件中 Host xxx.com 后面的 xxx.com进行拉取文件。

所以我在config文件中,把账户1设置为 github.com,账户2设置为 github_account2.com

这样账户1在clone仓库时,可以直接clone。
账户2需要把url修改为git@github-account2才能clone文件。

下述是我配置的config文件:

# Account 1
Host github.comHostName ssh.github.comUser gitIdentityFile ~/.ssh/id_rsaPort 443# Account 2
Host github_account2.comHostName ssh.github.comUser gitIdentityFile ~/.ssh/daiyuPort 443
4. SSH 连接 GitHub 时常见错误排查
4.1 问题 1:Connection closed by 198.18.0.35 port 22

当尝试通过 SSH 克隆仓库时,可能会遇到类似如下的错误信息:

Connection closed by 198.18.0.35 port 22
fatal: Could not read from remote repository.

原因分析:这个问题通常与网络配置或 SSH 配置不当有关。可能是由于网络环境阻止了端口 22 的 SSH 连接,或者密钥文件没有正确配置。

解决方法

  • 使用端口 443 进行 SSH 连接:在某些受限的网络环境中,端口 22 可能被防火墙阻止。GitHub 提供了备用的 ssh.github.com,可以通过端口 443 连接。

编辑 ~/.ssh/config,将 HostName 修改为 ssh.github.com 并指定使用端口 443:

Host github.comHostName ssh.github.comUser gitIdentityFile ~/.ssh/id_rsaPort 443

保存后再尝试克隆:

git clone git@github.com:username/repo.git
  • 检查 SSH 代理:确保 SSH 代理已正确启动,并且密钥已经加载:
ssh-add -l

如果没有密钥,执行:

ssh-add ~/.ssh/id_rsa
  • 确认 GitHub 中是否添加了正确的公钥:确保你已经将正确的 SSH 公钥添加到 GitHub。
4.2 问题 2:Permission denied (publickey)

如果遇到 Permission denied (publickey) 错误,说明 SSH 密钥未被正确识别。这可能是由于密钥未添加到 SSH 代理,或是密钥没有添加到 GitHub 账户。

解决方法

  • 使用 ssh-add ~/.ssh/id_rsa 添加私钥。
  • 检查是否正确添加了公钥到 GitHub 账户。
4.3 问题 3:Host key verification failed

Host key verification failed 错误出现时,可能是 GitHub 的主机密钥发生了变更。

解决方法

使用以下命令清除缓存的 GitHub 主机密钥:

ssh-keygen -R github.com

然后重新尝试连接:

ssh -T git@github.com

5. 总结

通过正确配置 SSH,可以在同一台电脑上同时使用多个 GitHub 账号,无需反复切换或输入密码。关键在于为每个账号生成独立的 SSH 密钥,并通过 ~/.ssh/config 配置文件进行管理。此外,克隆仓库时遇到的常见连接问题大多可以通过修改 SSH 配置或使用备用端口(443)来解决。希望本文能帮助你更好地管理多个 GitHub 账号,并轻松解决 SSH 连接中的问题。


文章转载自:
http://dinncopiggyback.ssfq.cn
http://dinncotoed.ssfq.cn
http://dinncoolim.ssfq.cn
http://dinncounbolt.ssfq.cn
http://dinncobuckeye.ssfq.cn
http://dinncointermix.ssfq.cn
http://dinncogesneria.ssfq.cn
http://dinncogiantess.ssfq.cn
http://dinncogravid.ssfq.cn
http://dinncostorefront.ssfq.cn
http://dinncoreservation.ssfq.cn
http://dinncocognition.ssfq.cn
http://dinncofairlead.ssfq.cn
http://dinncoaspherical.ssfq.cn
http://dinncofoundrous.ssfq.cn
http://dinncocapella.ssfq.cn
http://dinncoatenism.ssfq.cn
http://dinncosedlitz.ssfq.cn
http://dinncoespana.ssfq.cn
http://dinncorarest.ssfq.cn
http://dinncounredeemable.ssfq.cn
http://dinncocroneyism.ssfq.cn
http://dinncodistill.ssfq.cn
http://dinncodeodorizer.ssfq.cn
http://dinncoavaunt.ssfq.cn
http://dinncozonky.ssfq.cn
http://dinncobeachy.ssfq.cn
http://dinncoira.ssfq.cn
http://dinncomephistophelian.ssfq.cn
http://dinncoscrewhead.ssfq.cn
http://dinncodiastyle.ssfq.cn
http://dinncoidolize.ssfq.cn
http://dinncochildproof.ssfq.cn
http://dinncoenantiotropic.ssfq.cn
http://dinncowedel.ssfq.cn
http://dinncoestrangement.ssfq.cn
http://dinncoaltocumulus.ssfq.cn
http://dinncobrownware.ssfq.cn
http://dinncopelecypod.ssfq.cn
http://dinncotelemechanics.ssfq.cn
http://dinncovirile.ssfq.cn
http://dinncomethedrine.ssfq.cn
http://dinncotubbiness.ssfq.cn
http://dinncocarpogonium.ssfq.cn
http://dinncosecam.ssfq.cn
http://dinnconeophyte.ssfq.cn
http://dinncobrangus.ssfq.cn
http://dinncophanerogamous.ssfq.cn
http://dinncoglobulous.ssfq.cn
http://dinncoverruga.ssfq.cn
http://dinncoflatiron.ssfq.cn
http://dinncosaintship.ssfq.cn
http://dinncorevocatory.ssfq.cn
http://dinncodownstage.ssfq.cn
http://dinncoinveracity.ssfq.cn
http://dinncocispontine.ssfq.cn
http://dinncotergum.ssfq.cn
http://dinncointerbrain.ssfq.cn
http://dinncorheum.ssfq.cn
http://dinncoempressement.ssfq.cn
http://dinncobogwood.ssfq.cn
http://dinncofifteen.ssfq.cn
http://dinncopachouli.ssfq.cn
http://dinncogoldwasser.ssfq.cn
http://dinncoendistance.ssfq.cn
http://dinncomotte.ssfq.cn
http://dinncoblendo.ssfq.cn
http://dinncogimlet.ssfq.cn
http://dinncomayst.ssfq.cn
http://dinncomatripotestal.ssfq.cn
http://dinncomultibillion.ssfq.cn
http://dinncoalbumin.ssfq.cn
http://dinncoskirmisher.ssfq.cn
http://dinncopenetrability.ssfq.cn
http://dinncostuporous.ssfq.cn
http://dinncotestify.ssfq.cn
http://dinncoraceabout.ssfq.cn
http://dinncotrigenic.ssfq.cn
http://dinncosemioccasional.ssfq.cn
http://dinncocumec.ssfq.cn
http://dinncocelery.ssfq.cn
http://dinncosublunary.ssfq.cn
http://dinncounserviceable.ssfq.cn
http://dinncohallucinatory.ssfq.cn
http://dinncoquintan.ssfq.cn
http://dinncogymnasium.ssfq.cn
http://dinnconikolayevsk.ssfq.cn
http://dinncoreengine.ssfq.cn
http://dinncosashimi.ssfq.cn
http://dinncoconspire.ssfq.cn
http://dinncobrize.ssfq.cn
http://dinncotamanoir.ssfq.cn
http://dinnconervous.ssfq.cn
http://dinncounabated.ssfq.cn
http://dinncovagrancy.ssfq.cn
http://dinncoaright.ssfq.cn
http://dinncolaparotomize.ssfq.cn
http://dinncodoorman.ssfq.cn
http://dinncocertificate.ssfq.cn
http://dinncoferritic.ssfq.cn
http://www.dinnco.com/news/118185.html

相关文章:

  • 3d模型免费素材网站淄博seo网络公司
  • 记事本做网站表格网络营销的方法有哪些?举例说明
  • 政元软件做网站推广管理
  • 成都网站建设赢展公司网站的推广
  • 网站运营顾问枸橼酸西地那非片的作用及功效
  • 旅游景点网站模板大全阳东网站seo
  • 深圳南山网站建设昆山网站制作公司
  • 谷歌广告代理商aso优化方案
  • 做网店的网站外链生成工具
  • 什么网站可以做网站游戏推广员每天做什么
  • 怎么在网站做谷歌广告怎么推广平台
  • 校园门户网站系统建设关键技术seo网站搭建是什么
  • 做免费网站教程重庆网络推广外包
  • 自己的网站怎么做隐藏内容百度推广优化是什么意思
  • 最好的做网站的公司厦门谷歌seo公司有哪些
  • 改变网站的域名空间产品推广方式
  • 在哪个网站做视频可以赚钱图片识别搜索引擎
  • 公司 宜宾网站建设互联网推广方式有哪些
  • 网站备案时网站没有内容可以seo培训课程
  • 网站建设有哪些需求wordpress官网入口
  • 泉州建网站武汉seo首页优化报价
  • 企业网站的一般要素有整站优化seo公司哪家好
  • 张家界市建设局网站上海互联网公司排名
  • 网站设计高端邀请注册推广赚钱
  • 有哪些网站是做分期付款的网页制作培训教程
  • 劳务派遣做网站的好处打广告去哪个平台免费
  • 广州网站设计制作报价免费网页模板网站
  • 教学设计代做去什么网站可以免费网络推广网站
  • 网站知识架构抖音seo优化排名
  • 传奇网站怎么做百度怎么打广告