• Home
  • 归档
文章检索 作品与友邻 关于我
暴君乔博客
Home 归档

ssh-key构建以及连接github操作

发布于: 2018-08-05
更新于: 2023-07-09
文章目录
  1. ssh【Secure Shell】
    1. ssh 的介绍
    2. ssh 的原理
    3. 连接事项

ssh【Secure Shell】

ssh 的介绍

secure shell 应用层上实现安全交流的协议

  • ssh 连接方式
    • 基于口令【帐号密码】
    • 基于密钥【也就是我们连上[email protected]时所使用的方法】

ssh 的原理

  • SSH:
    • server create public key
    • receiver get the key and create its’ public and private key.
    • resent the ‘receiver’public key to server

      server will send the data which is encrypted (use the receiver’s public key encrypt). Receiver get the data and decrypt it with receiver’s private key.

ssh 安全问题

  • 通过公钥进行伪装攻击怎么办?

    现在普遍的方法是通过将公钥存于证书中,而用户通过去相信一些大型的、可靠的证书机构 GlobalSign、Comodo、Go Daddy、 Digicert 等等

连接事项

系统

  • windows:
    • 注意使用 git bash 来进行连接操作,cmd 下将无那些指令
    • 而用 git bash 默认生成时,文件存在于~/.ssh/id_rsa,需要用指令获取密钥
  • Linux:
    • linux 的话同 git bash 一步,按流程走即可

具体步骤

  • How to connect to github by ssh:
# 这里回车两次,不设置密令,同时这里可以设置生成路径以及密钥名字
ssh-keygen -t rsa -C "yourEmail"
# eval $(ssh-agent -s)等同于下面两句
ssh-agent -s
eval `ssh-agent`
# Linux: you need to make this file touchable
# chmod 600 id_rsa
# 若需要清除之前的key,可以执行ssh-add -D 清除所有key
ssh-add id_rsa
# (you need to add the id_rsa.pub to the github's deployer key)
ssh -T [email protected]
  • Bug【无法添加】

    • 有多个 key 需要添加

      通过设置 config,进行详细配置【在~/.ssh 目录下 执行touch config,然后添加以下代码】

    # github
    Host github.com
      HostName github.com
      PreferredAuthentications publickey
      IdentityFile ~/.ssh/id_rsa
    # gitlab 以此类推进行添加
    Host gitlab.....
    
  • 生成 key 给谁

    • 给对应的仓库 repository,则添加到对应的 deploy key
    • 但如果是像我们开发者这种,可以添加到 user settings 里面的 deploy key,这样就可以一劳永逸地上传,更新库了
  • ssh 的指令解释

    • ssh-key add id_rsa

      添加私钥

    • ssh -T [email protected]

      激活密钥

    • ssh-add -l

      显示所有 key

    • ssh-add -D

      清除所有 key

如何不再重复设置 ssh-key

# 本地的ssh目录
cd ~/.ssh
# 生成ssh key
ssh-keygen -t rsa -C "[email protected]"
# 打印公钥 将公钥添加到github中
cat id_rsa.pub
# 连接github
ssh -T [email protected]
ssh-key构建以及连接github操作
/archives/35729c7e/
作者
tyrantqiao
发布于
2018-08-05
更新于
2023-07-09
许可协议
CC BY-NC-SA 4.0
赏

蟹蟹大佬的打赏,大家一起进步

支付宝
微信
  • Git
  • ssh

扫一扫,分享到微信

微信分享二维码
hexo从入门到优化手册
© 2026 tyrantqiao 本站总访问量次 本站访客数人次 载入天数...载入时分秒...
  • 文章检索
  • 作品与友邻
  • 关于我

展开标签

  • 随笔
  • 旅行
  • Java
  • 面经
  • 源码
  • 计算机网络
  • 技术
  • 架构
  • Hadoop
  • IDEA
  • maven
  • JDK
  • Linux
  • MySQL
  • 性能
  • 数据库
  • Redis
  • MQ
  • Spring
  • SquirrelFin
  • 记账
  • Android
  • 个人财务
  • unity
  • TIDB
  • chatgpt
  • 前端
  • Vue
  • Git
  • Hexo
  • shadowsocks
  • 问题排查
  • 业务
  • JVM
  • 算法
  • nginx
  • ssh
  • Python
  • 爬虫
  • test
  • vim
  • 影视剧
  • 中间件
  • 事务
  • 表达
  • 运动
  • mybatis
  • AI
  • 产品
  • 家装
  • 土巴兔
  • 域名
  • github
  • 软件
  • 个人项目
  • Leaves
  • Chrome
  • 浏览器插件
  • 开源
  • Balance Voice
  • 穿搭
  • 幽默
  • 画画
  • 缓存
  • 摄影
  • c
  • 课程设计
  • 调酒
  • 设计模式
  • 数学

Collection

作品与友邻

我做的小工具、朋友的站点和一些长期值得回访的灵感来源。

  • 土 土巴兔 AI 导购交互演示 可点击体验用户导购、平台运营、装修公司、材料商及 AI 话术知识库的多端增长流程。 /demos/tubatu-ai-guide/
  • L Leaves 行程记录 我做的行程记录页面小工具,用来沉淀旅行路线、日程安排和途中的灵感。 https://leaves.tyrantqiao.com/
  • 本 本网站主题yilia设计者的主页 http://litten.me/
tyrantqiao的头像

tyrantqiao

github rss qq mail facebook linkedin

About

关于我

代码、海浪和持续折腾,都是生活的一部分。

<div class="aboutme-card"> <p class="aboutme-eyebrow">tyrantqiao</p> <h3>Java 全栈开发</h3> <p>常年和 Java、后端服务、前端工程、数据与部署打交道,喜欢把复杂问题拆开、写清楚,也把踩坑过程整理成文章留给后来的人。</p> <div class="aboutme-tags"> <span>Java</span> <span>Full Stack</span> <span>Backend</span> <span>Frontend</span> <span>Extreme Sports</span> </div> <p>工作之外偏爱冲浪等极限运动,享受在浪上找平衡,也享受在代码里找边界。</p> <div class="aboutme-contact"> <a href="mailto:[email protected]">Gmail</a> <a href="mailto:[email protected]">QQ Mail</a> </div> </div>