第一:检查.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. 【leetcode】Word Ladder II(hard)★ 图 回头看

    Given two words (start and end), and a dictionary, find all shortest transformation sequence(s) from ...

  2. linux 5.5 开xmanager远程

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

  3. live555源码研究(四)------UserAuthenticationDatabase类

    一.UserAuthenticationDatabase类作用 1,用户/密码管理 2,鉴权管理 二.类UserAuthenticationDatabase继承关系图                 ...

  4. P94、面试题12:打印1到最大的n位数

    题目:输入数字n,按顺序打印出从1最大的n位十进制数.比如输入3,则打印出1,2,3一直到最大的3位数999. 思路:先把字符串中的每一个数字都初始化为‘0’,然后每一次为字符串表示的数字加1,再打印 ...

  5. /etc/bashrc,用户目录下.bashrc有什么区别?

    /etc/bashrc,用户目录下.bashrc有什么区别? 一个是针对整个系统所有用户的,一个是针对特定用户的./etc/bashrc修改了以后要重启系统才生效,而用户目录下.bashrc修改了以后 ...

  6. node.js 模块之url和querystring模块

    关系如下: url.parse(string).query | url.parse(string).pathname | | | | | ------ ------------------- http ...

  7. C# 第三方DLL,可以实现PDF转图片,支持32位系统、64位系统

    itextsharp.dll,是一个开源的在C#中用来生成PDF文档的库文件,不少C#爱好者用它制作出了PDF文档生成器.使用时只需在你的C#项目中添加引入此组件即可,使用方法网上有很多,自己查阅一下 ...

  8. Mongodb的范式化和反范式化

    如果是涉及到一对多的数据格式,可使用文档引用范式化数据. 在一个,User对象中,如果涉及到工作信息或者联系地址的,这些信息会频繁的进行访问,可使用嵌入式文档对数据进行反范式化.

  9. js 动态计算折扣后总价格

    <script type="text/javascript"> <!---计算折扣后的总价格---> function outtotalprice(i) { ...

  10. bzoj1079: [SCOI2008]着色方案

    ci<=5直接想到的就是5维dp了...dp方程YY起来很好玩...写成记忆化搜索比较容易 #include<cstdio> #include<cstring> #inc ...