SSH连接GitHub并配置ssh key

配置git的ssh提交,主要需要以下三步:

  1.设置Git的user name和email
  2.生成ssh
  3.配置git 的ssh key

一、设置Git的user name和email

//用户名写自己想写的,比如:mmzsit
$ git config --global user.name "mmzsit"
//邮箱写自己的,比如我的:mmzzsblog@163.com
$ git config --global user.email "mmzzsblog@163.com"

二、本地生成ssh key

新打开一个终端:

1、检查ssh keys是否存在

$ ls -al ~/.ssh

如果目录下面没有id_rsa、id_rsa.pub则表示key不存在

2、生成ssh key

$ ssh-keygen -t rsa -b 4096 -C "mmzsblog@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Administrator/.ssh/id_rsa.
Your public key has been saved in /c/Users/Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:RB6dXNLR7PFAF3Z4QcKHp10cumJ1iOfMymzpdSKWmPk mmzsblog@163.com
The key's randomart image is:
+---[RSA 4096]----+
| oo.++*+O*|
| o .+.oo@+=|
| o . *=*.|
| . *.+..|
| S o = |
| B = |
| + X o . |
| = o o |
| E |
+----[SHA256]-----+

3、将ssh key添加到ssh-agent

先确认ssh-agent是可用的

$ eval $(ssh-agent -s)
Agent pid 10336

将ssh key添加到ssh-agent

$ ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/Administrator/.ssh/id_rsa (mmzsblog@163.com)

三、配置git的ssh key

1、将ssh key配置到github

登录github–>点击头像–>选择"settings"–>选择左侧菜单"SSH and GPG keys"–>点击右上角的"NEW SSH key"–> 新建ssh 链接。

复制key内容:

$ clip < ~/.ssh/id_rsa.pub

TiTle 可随意填写(建议和第一步设置的用户名一致) ;
Key是第二步生成的 id_rsa.pub文件 的内容全部复制到此处(id_rsa.pub默认在C:\Users\Administrator.ssh目录下)。

2、测试ssh key的配置情况

$ ssh -t git@github.com
PTY allocation request failed on channel 0

到这里就配置好了!

SSH连接GitHub并配置ssh key的更多相关文章

  1. windows10 配置SSH连接Github、配置SSH Key

    由于你的本地Git仓库和GitHub仓库之间的传输是通过SSH加密的,所以,需要设置SSH key. 第1步:创建SSH Key.在用户主目录下[我的电脑是C:\Users\ad],看看有没有.ssh ...

  2. window下配置SSH连接GitHub、GitHub配置ssh key

    window下配置SSH连接GitHub.GitHub配置ssh key   此经验分两部分: 第一部分介绍:在windows下通过msysGit(Git for windows.Git Bash)配 ...

  3. git连接通过ssh连接github

    解决 git连接通过ssh连接github 1. 首先产生一个rsa的私钥和公钥 ssh-keygen -t rsa -C "15950093214@163.com"  //你的g ...

  4. kettle通过SSH连接Mysql数据库(SSH隧道)

    kettle通过SSH连接Mysql数据库(SSH隧道) Kettle无法直接连接使用SSH通道的MySQL,通过SSH隧道(推荐)或者需要借助工具PuTTY(不用时需要注销不推荐),具体操作如下所示 ...

  5. window下配置SSH连接GitHub、GitHub配置ssh key(转)

    转自:http://jingyan.baidu.com/article/a65957f4e91ccf24e77f9b11.html 此经验分两部分: 第一部分介绍:在windows下通过msysGit ...

  6. 解决GitHub未配置SSH key提示错误信息

    git push -u origin master Permission denied (publickey). fatal: Could not read from remote repositor ...

  7. GitHub如何配置SSH Key

    https://github.com/xiangshuo1992/preload.git git@github.com:xiangshuo1992/preload.git 这两个地址展示的是同一个项目 ...

  8. Gitee(码云)、Github同时配置ssh key

    一.cd ~/.ssh 二.通过下面的命令,依次生成两个平台的key $ ssh-keygen -t rsa -C "xxxxxxx@qq.com" -f "github ...

  9. 通过ssh连接github

    1.检查是否已经存在ssh key $ cd ~/.ssh $ ls 如果该目录下存在id_rsa/id_rsa.pub/known_hosts这三个文件,则已经存在ssh key 直接跳转到第3步 ...

随机推荐

  1. position属性sticky和fixed的区别比较

    position属性之fixed fixed总是以body为定位时的对象,总是根据浏览器窗口来进行元素的定位,通过left,right,top,bottom属性进行定位. <!DOCTYPE h ...

  2. [LeetCode] Advantage Shuffle 优势洗牌

    Given two arrays A and B of equal size, the advantage of A with respect to B is the number of indice ...

  3. python批量提取eml附件

    从批量eml文件中提取附件,使用方式如下 代码如下 import email import os import sys #获取eml附件信息 def Get_Annex_Message(FilePat ...

  4. SEED实验——return-to-libc实验

    实验概述 本实验的学习目标是让学生获得缓冲区溢出攻击的一种有趣变体——return-to-libc攻击实验的亲身体验.这种攻击可以绕过目前在主要linux操作系统中实现的现有保护方案.利用缓冲区溢出漏 ...

  5. JavaEE开发之Spring中的依赖注入与AOP编程

    上篇博客我们系统的聊了<JavaEE开发之基于Eclipse的环境搭建以及Maven Web App的创建>,并在之前的博客中我们聊了依赖注入的相关东西,并且使用Objective-C的R ...

  6. MySQL 使用自增ID主键和UUID 作为主键的优劣比较详细过程(从百万到千万表记录测试)

    测试缘由 一个开发同事做了一个框架,里面主键是uuid,我跟他建议说mysql不要用uuid用自增主键,自增主键效率高,他说不一定高,我说innodb的索引特性导致了自增id做主键是效率最好的,为了拿 ...

  7. [Swift]LeetCode107. 二叉树的层次遍历 II | Binary Tree Level Order Traversal II

    Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left ...

  8. [Swift]LeetCode250.计数相同值子树的个数 $ Count Univalue Subtrees

    Given a binary tree, count the number of uni-value subtrees. A Uni-value subtree means all nodes of ...

  9. [Swift]LeetCode382. 链表随机节点 | Linked List Random Node

    Given a singly linked list, return a random node's value from the linked list. Each node must have t ...

  10. [Swift]LeetCode905. 按奇偶排序数组 | Sort Array By Parity

    Given an array A of non-negative integers, return an array consisting of all the even elements of A, ...