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

wsl使用git

前言:文章类型 > 笔记

安装git

sudo apt-get install git

查看版本(只用前面那句就行)

git --version; git credential-manager --version

用户配置

git config --global user.name "Your Name"
git config --global user.email "youremail@domain.com"

生成密钥

ssh-keygen -t rsa -C "youremail@domain.com"

查看并复制公钥

cat ~/.ssh/id_rsa.pub

# 你会看到类似这样的内容:# ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQD...(很长一串)... youremail@domain.com

👌以下内容可忽略
👌SSH密钥指纹(Fingerprint)
👌以上内容为实践,以下内容由ai生成,可忽略。
👌介绍:

SSH密钥指纹(Fingerprint)

指纹是公钥的哈希值,主要用于验证公钥的真实性和唯一性,而不是用于身份认证。以下是指纹的主要用途:

验证公钥的真实性:当你第一次连接到远程服务器(如GitHub)时,SSH客户端会显示该服务器的公钥指纹,你可以通过对比已知的正确的指纹来确认你连接的是正确的服务器,而不是恶意的中间人。
唯一标识公钥:指纹是公钥的简短表示,方便人类比较和识别。公钥本身很长,而指纹较短,易于处理。

安全验证:在团队协作或自动化脚本中,可以通过比较指纹来确保使用的公钥是正确的。

在SSH连接过程中的作用:当你第一次通过SSH连接到新服务器时,会看到类似这样的提示:

text The authenticity of host ‘github.com (140.82.121.3)’ can’t be
established. ECDSA key fingerprint is
SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you
want to continue connecting (yes/no)?
你可以通过对比GitHub官方公布的指纹(可以在GitHub的文档中找到)来确认你连接的是真正的GitHub服务器,而不是冒名顶替者。

在GitHub中,你也可以看到你添加的公钥的指纹,以便于管理。

所以,指纹是一个用来验证公钥的便捷工具,但并不是用于身份认证的凭证。身份认证时需要使用私钥,而远程服务器使用公钥来验证你的私钥。
SSH密钥指纹(Fingerprint)的主要用途是验证和识别密钥,而不是用于身份认证。以下是它的具体作用:

1.验证密钥真实性(防止中间人攻击)当你第一次连接新服务器时,SSH会显示服务器的公钥指纹: ```The authenticity of host ‘github.com (140.82.121.3)’ can’t be established.

ECDSA key fingerprint is
SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8. Are you sure you
want to continue connecting (yes/no)? ```你可以:

  • 对比GitHub官方公布的指纹(在GitHub文档中)
  • 确认你连接的是真正的GitHub,而不是假冒的服务器
2.快速识别和区分密钥
  • 指纹是公钥的哈希值,短小易读
  • 便于人工核对,避免比较长长的公钥字符串
3.在GitHub等平台上的用途
  • GitHub会显示你已添加密钥的指纹
  • 方便你确认添加了正确的密钥
  • 删除密钥时可以通过指纹识别
4.实际使用场景示例
检查本机已添加密钥的指纹bash ssh-keygen -lf ~/.ssh/id_rsa.pub输出: ```3072 SHA256:L8bheKiPGxAix5CX9OYQN/2qA33xv/GNugf4yw2JsXQ

youremail@domain.com (RSA) ```

查看GitHub服务器指纹bash ssh-keyscan github.com | ssh-keygen -lf -输出(应与官方公布的一致): ```256 SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8 (ECDSA) 256

SHA256:p2QAMXNIC1TJYWeIOttrVc98/R1BUFWu3/LiyKgUfQM (ED25519) 3072
SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s (RSA) ```

验证连接到的服务器bash ssh -T git@github.com首次连接会显示指纹让你确认。
5.重要区别总结| 项目 | 公钥 (Public Key) | 指纹 (Fingerprint) | |------|-------------------|---------------------| |用途|

身份认证(添加到GitHub) | 验证和识别 | |格式| 长字符串(ssh-rsa AAAAB3N...) |
短哈希值(SHA256:xxxx) | |长度| 几百个字符 | 几十个字符 | |可逆性| 原始数据 |
哈希值,不可逆 | |使用场景| 添加到服务端进行认证 | 核对、验证、管理 |

简单类比:
  • 公钥≈ 你的身份证原件(需要提交给GitHub)
  • 指纹≈ 身份证号码(用于快速识别和核对)
  • 私钥≈ 你的签名/印章(用于证明你是你)

结论:指纹是个"校验工具",帮你确认"对的钥匙"放在了"对的锁"上,但它本身不是钥匙。你需要的是公钥本身去GitHub认证,而不是它的指纹。


提交代码 懒得写了复制粘贴的 自己变通吧,提交前先git add .

…or create a new repository on the command line
echo “# navdemo” >> README.md
git init
git add README.md
git commit -m “first commit”
git branch -M main
git remote add origin git@github.com:yumeko2333333/navdemo.git
git push -u origin main

…or push an existing repository from the command line
git remote add origin git@github.com:yumeko2333333/navdemo.git
git branch -M main
git push -u origin main

# 懒得编辑了自己看吧# 实践如此jh@DESKTOP-885GOSQ:/mnt/e/YumeWorkFiles/Aaaa-t/Abbb-t/A-TestingDemo$cdnavdemo jh@DESKTOP-885GOSQ:/mnt/e/YumeWorkFiles/Aaaa-t/Abbb-t/A-TestingDemo/navdemo$gitinit Reinitialized existing Git repositoryin/mnt/e/YumeWorkFiles/Aaaa-t/Abbb-t/A-TestingDemo/navdemo/.git/ jh@DESKTOP-885GOSQ:/mnt/e/YumeWorkFiles/Aaaa-t/Abbb-t/A-TestingDemo/navdemo$gitcommit -m"first commit"On branch main Initial commit Untracked files:(use"git add <file>..."to includeinwhat will be committed)index.html linksdata.json login.html notes.html notesdata.json ok/ others/ recipes.html recipes10.html recipes9.html recipesdata.json reminders.json version/ webhook.php nothing added to commit but untracked files present(use"git add"to track)jh@DESKTOP-885GOSQ:/mnt/e/YumeWorkFiles/Aaaa-t/Abbb-t/A-TestingDemo/navdemo$gitadd.jh@DESKTOP-885GOSQ:/mnt/e/YumeWorkFiles/Aaaa-t/Abbb-t/A-TestingDemo/navdemo$gitcommit -m"first commit"[main(root-commit)19cd883]first commit21files changed,22511insertions(+)create mode100644index.html create mode100644linksdata.json create mode100644login.html create mode100644notes.html create mode100644notesdata.json create mode100644ok/changeimgcolor.html create mode100644others/jsex1.html create mode100644others/mousehightlight.js create mode100644others/newreminders3.html create mode100644others/snake1.js create mode100644recipes.html create mode100644recipes10.html create mode100644recipes9.html create mode100644recipesdata.json create mode100644reminders.json create mode100644version/index1.html create mode100644version/index_testing4.html create mode100644version/notes1/notes.css create mode100644version/notes1/notes.js create mode100644version/notes1/notes1.html create mode100644webhook.php jh@DESKTOP-885GOSQ:/mnt/e/YumeWorkFiles/Aaaa-t/Abbb-t/A-TestingDemo/navdemo$gitpush -u origin main Enumerating objects:27, done. Counting objects:100%(27/27), done. Delta compression using up to8threads Compressing objects:100%(26/26), done. Writing objects:100%(27/27),120.81KiB|798.00KiB/s, done. Total27(delta6), reused0(delta0), pack-reused0remote: Resolving deltas:100%(6/6), done. To github.com:yumeko2333333/navdemo.git *[new branch]main ->main branch'main'setup to track'origin/main'.jh@DESKTOP-885GOSQ:/mnt/e/YumeWorkFiles/Aaaa-t/Abbb-t/A-TestingDemo/navdemo$
http://www.cnnetsun.cn/news/167576.html

相关文章:

  • 二叉搜索树的最近公共祖先:别再蛮力了,用规则思维找“血缘关系”
  • 推荐6个AI论文网站,提供降重与自然改写功能避免标红
  • 智能学术支持:6个AI论文平台解析,自动润色让内容更专业
  • 从手动测试到自动化测试的转型之路:策略、挑战与未来
  • 大数据工程师必看:批处理性能优化的10个黄金法则
  • 2026年AI全面爆发!AI原生、物理AI、多模态与世界模型的革命性变革
  • 【扣子Coze教程】文案一键仿写+飞书自动发布
  • 提示词工程精华总结:掌握ICIO框架与五大核心要素,AI应用效率翻倍,建议收藏!
  • 还在手动选品?RPA+AI生成希音爆款推荐,效率提升100倍![特殊字符]
  • 8个AI论文工具,自考学生轻松搞定毕业论文!
  • 8个降AI率工具推荐,继续教育学生必备
  • CTFer常见高频工具清单
  • 痞子衡嵌入式:16MB以上NOR Flash地址模式切换会造成软复位后i.MXRT无法正常启动
  • 爬山算法:无需微积分的机器学习之旅
  • 【Ctfer训练计划】——命令执行的解题技巧(持续更新中)
  • CTF wed安全(攻防世界)练习题
  • CTF进阶解题,掌握这套框架+技巧就够了!
  • Vue面试中,经常会被问到的面试题/Vue知识点整理,收藏这篇就够了
  • 复习2——线程(pthread)
  • 【DPFSP问题】基于matlab鳄鱼伏击算法CAOA求解分布式置换流水车间调度DPFSP【含Matlab源码 14744期】
  • 格雷厄姆特价股票策略在新能源行业的应用挑战
  • 毕业论文写不下去?百考通AI平台,一句话生成完整初稿,助你高效通关!
  • 【NWFSP问题】鳄鱼伏击算法CAOA求解零等待流水车间调度问题NWFSP【含Matlab源码 14745期】
  • 还在手动回复希音咨询?RPA+AI自动客服,效率提升30倍![特殊字符]
  • AI应用开发全景图:从LLM到Agent的硬核指南!这些大模型核心概念你必须懂
  • 揭秘Open-AutoGLM如何实现毫秒级快递轨迹更新:技术架构全解析
  • 换个角度看境外支付系统:警惕金融风险之安全测试实践
  • Home-Assistant智能家居平台搭建与远程控制
  • 盲盒小程序定制案例|轻松打造专属盲盒乐园
  • 【Open-AutoGLM快递轨迹追踪实战】:掌握AI驱动物流监控的5大核心技术