第一:检查.ssh是否存在(ls -al ~/.ssh)

$ ls -al ~/.ssh
Lists the files in your .ssh directory, if they exist

第二:产生新的SSH key(ssh-keygen -t rsa -C "your_email@example.com")

$ ssh-keygen -t rsa -C "your_email@example.com"
Creates a new ssh key, using the provided email as a label
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [Press enter]
Enter passphrase (empty for no passphrase): [Type a passphrase][Press enter]
Enter same passphrase again: [Type passphrase again][Press enter]
产生的结果如下:
Your identification has been saved in /c/Users/you/.ssh/id_rsa.
Your public key has been saved in /c/Users/you/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com 添加新的key到ssh-agent:
$ ssh-agent -s
Agent pid 59566
$ ssh-add ~/.ssh/id_rsa 如果出现Could not open a connection to your authentication agent
解决办法:
$ eval $(ssh-agent)
Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
Identity added:/c/Users/you/.ssh/id_rsa(/c/Users/you/.ssh/id_rsa) 

第三:添加ssh key到github中

$ clip < ~/.ssh/id_rsa.pub
Copies the contents of the id_rsa.pub file to your clipboard
如下图所示:

第四:检查如否配置成功

在Git Bash中输入:

$ ssh -T git@github.com
Attempts to ssh to github

或许会出现:

The authenticity of host 'github.com (207.97.227.239)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?

这是正常的,输入yes即可

Hi username! You've successfully authenticated, but GitHub does not
provide shell access.

第五:改变git的remote url:将https://github.com/xxxx.git改成git@github.com:xxxx.git

即修改.git/config文件

文章摘自:https://help.github.com/articles/generating-ssh-keys

git ssh key for github的更多相关文章

  1. windows系统如何添加ssh key到github

    我自己的电脑安装了git后,从来没有用过,今天偶然用了一次,发现不能pull到东西,报错说我没有权限,于是我网上搜索了一下,应该是我没有配置ssh key的原因,相信很多人都有和我一样的经历吧,这里呢 ...

  2. 【Linux】配置SSH Key到GitHub/GitLab

    Linux配置SSH Key到GitHub/GitLab 准备工作 首先检查下本机是否已经安装了SSH,在终端输入ssh即可: 如果没有安装进行yum安装 # yum -y install opens ...

  3. MAC如何生成SSH key与GitHub关联

    一.检查 SSH key 是否存在 在终端输入如下代码: ls -al ~/.ssh 如果没有,终端显示如下: No such file or directory 如果有,终端显示如下: ➜ ~ ls ...

  4. 简易搭建git仓库、关联远程和本地仓库方法。克隆仓库方法。同一台电脑上创建两个git ssh key方法。

    一,在github上建仓库 react-js-antd-demo: 二:将远程仓库与本地仓库关联 git remote add origin git@github.com:begin256/react ...

  5. 如何生成git ssh key

    公司有自己的git版本控制,自己注册账号后,管理员同意,就可以查看项目代码了,但是要克隆的话需要在本地生成git ssh key 一.进入.ssh文件夹. cd ~/.ssh 若没有.ssh文件夹,则 ...

  6. git ssh key配置&解决git每次输入密码

    git ssh key配置&解决git每次输入密码:https://blog.csdn.net/qq_42817227/article/details/81415404

  7. SSH Key连接github提示Permission denied (publickey).错误

    root@debian64:/home/xiaoliuzi/.ssh/key_backup# ssh -T git@github.com The authenticity of host 'githu ...

  8. (Git 学习)Git SSH Key 创建步骤

    首先感谢segmentfalut上的朋友对我帮助. 首先:查看你是否有../ssh 这个文件:怎么查看:找到你的git安装目录,在安装目录下查看是否./ssh,以我的为例: 在C盘/Users/11/ ...

  9. git ssh key生成

    重装系统后,需要重新安装git,ssh key便是遇到的其中一个问题,具体解决办法如下: 1.安装好git客户端后,查看本地是否有.ssh文件,命令如下:mkdir ~/.ssh 2.如果没有该文件, ...

随机推荐

  1. [转载]MongoDB查询优化原则

    .在查询条件.排序条件.统计条件的字段上选择创建索引,可以显著提高查询效率. .用$or时把匹配最 多 结果的条件放在最前面,用$and时把匹配最 少 结果的条件放在最前面. .使用limit()限定 ...

  2. 关于Spark中RDD的设计的一些分析

    RDD, Resilient Distributed Dataset,弹性分布式数据集, 是Spark的核心概念. 对于RDD的原理性的知识,可以参阅Resilient Distributed Dat ...

  3. Debugging with GDB 用GDB调试多线程程序

    Debugging with GDB http://www.delorie.com/gnu/docs/gdb/gdb_25.html GDB调试多线程程序总结 一直对GDB多线程调试接触不多,最近因为 ...

  4. ***phpredis扩展安装总结

    phpredis扩展安装总结:PHP扩展安装在[root@iZ254lfyd6nZ lampp]# cd include 目录下创建一个目录phpredis下载扩展:wget https://gith ...

  5. HDU 2159 FATE (DP 二维费用背包)

    题目链接 题意 : 中文题不详述. 思路 : 二维背包,dp[i][h]表示当前忍耐值为i的情况下,杀了h个怪得到的最大经验值,状态转移方程: dp[i][h] = max(dp[i][h],dp[i ...

  6. linux 5.5 开xmanager远程

    http://bbs.cqsztech.com/dv_rss.asp?s=xhtml&boardid=3&id=11&page=9 linux 5.5 开xmanager远程 ...

  7. linux ubuntu删除引导 grub出现错误解决方案

    使用u盘启动PE系统 找到diskgenius软件,点击: 硬盘->重建主引导记录

  8. UIcollectionView的使用(首页的搭建2)

    2.2 直接购买的UIcollectionCell 2.2.1创建CFPromptBuyCell,继承自UICollectionViewCell,定义了标题和图片两个属性 2.2.2 在.m文件中定义 ...

  9. 版本管理工具介绍—Git篇

    前篇 如题,提起版本管理工具相信做C#开发 还是对Git比较陌生  我们可能更熟悉vss.svn 记录此文的目的 更是为以后的前段学习做基础  现在的技术比如nodeJs  angularJs ==都 ...

  10. 单独下载的Qt library则一般不带SSL(包括QT FAQ)

    http://www.cnblogs.com/E7868A/archive/2012/11/15/2771501.html http://www.oldcai.com/archives/208 htt ...