git 配置ssh key
第一次生成 ssh key
- 进入ssh目录
cd ~/.ssh
,再输入:ls ,查看文件,如果有.pub的文件,说明已有ssh key - 如果没有, 则生成秘钥:
ssh-keygen -t rsa -C "abc@163.com"
,否则参考配置多个 ssh key - 查看
id_rsa.pub
里面的内容,cat ~/.ssh/id_rsa.pub
key,并且复制到github/gitlab的settings 里
若要配置多个 ssh key
ssh-keygen -t rsa -C "abc@163.com"
//记得取名字,不然会覆盖原来的(id_rsa_personal.pub)重复上述步骤2,3
ssh服务器默认是去找id_rsa,现在需要把这个key添加到ssh-agent中,这样ssh服务器才能认识id_rsa_personal。
ssh-add -K ~/.ssh/id_rsa_personal 通过指定-K把SSH key导入到密钥链中 查看添加的结果: ssh-add -l
4.新建config文件进行配置,命令: vim config
,使得不同的ssh key 对应不同的账号
# gitlab
Host gitlab
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa # github
Host github
HostName github.com
User git
IdentityFile ~/.ssh/id_rsa_personal
说明:
- Host 可随意设置,只是后面ssh -T测试时要用到
- HostName 是
git@github.com:aloehh/react-mobx-demo.git
中的github.com
- IdentityFile 是私钥路径
最后:
全部配置好后,用ssh -T git@github
测试,出现'Hi aloehh! You've successfully authenticated, but GitHub does not provide shell access.'
则说明成功了(记得测试时把vpn关掉)
git 配置ssh key的更多相关文章
- git配置SSH Key,上传本地代码至github
git配置全局的name和email git config --global user.name "name" git config --global user.email &qu ...
- Git配置SSH Key
最近看到很多人在配置Git时,遇到很问题,网上教程千篇一律.这儿自己单独记录一份. Git配置SSH Key 1.检查本机是否有ssh key设置,切换到.ssh目录 $ cd ~/.ssh 或cd ...
- git配置ssh key并从github.com拉取repos
一.配置ssh key 1. 进入当前用户目录cd ~2. 生成ssh keyssh-keygen -t rsa -C "ABC@qq.com"ABC@qq.com账号必须是你登录 ...
- git 配置 .ssh key
1.安装git软件: 2.打开本地git bash,使用如下命令生成ssh公钥和私钥对: ssh-keygen -t rsa -C 'xxx@xxx.com' 然后一路回车(-C 参数是你的邮箱 ...
- 个人在git配置SSH Key遇到的问题以及解决方案
第一次用git上传代码到github,在这过程中遇到很多问题,在输入git命令的时候都小心翼翼,因为一不小心感觉就会出错.. 英语不好..在敲入git命令过程中各种错误提示勉强翻译下才看得懂 最后输入 ...
- Git 配置ssh key的步骤
First start by setting up your own public/private key pair set. This can use either DSA or RSA, so b ...
- git for windows配置SSH key
0. 前言 之前用过一段时间的git,后来迁移系统导致电脑中的git bash消失了,由于在上家公司版本管理用的svn,所以一直没有重新配置,目前工作中版本管理用的gitLab,后期计划将工作之外的精 ...
- 一台电脑上配置多个git的ssh key
前几天公司的代码库全部迁移到了阿里云上,在配置git的ssh key的时候遇到了一个问题,那就是自己的密钥在添加时提示已经存在,原来是自己的个人账号上已经添加过这个密钥了,公司分配的账号就不能再添加这 ...
- 解决GitHub未配置SSH key提示错误信息
git push -u origin master Permission denied (publickey). fatal: Could not read from remote repositor ...
随机推荐
- echarts x轴文字显示不全解决办法
标题:echarts x轴文字显示不全(xAxis文字倾斜比较全面的3种做法值得推荐):http://blog.csdn.net/kebi007/article/details/68488694
- js 判断所选时间(或者当前时间)是否在某一时间段的实现代码
var time_range = function (beginTime, endTime, nowTime) { var strb = beginTime.split (":") ...
- 利用sqlalchemy读取数据库 和pandas的Dataframe对象 互相生成
#导入pandas import pandas as pd import numpy as np #导入SqlAlchemy from sqlalchemy import create_engine ...
- (转)c++ 回调函数
https://www.cnblogs.com/chenyuming507950417/archive/2012/01/02/2310114.html 今天讨论下C/C++中的回调函数. 在理解“回调 ...
- python(字符串、列表、字典、元组、集合)的常用内置方法
一.字符串: lis='my name is maple' res=lis.count('m')#计算字符串内相同字符的个数 print(res) lis='my name is maple' res ...
- Methods for follow-up research of exome analysis:外显子后续分析研究思路总结
外显子后续分析研究思路一般有以下几种(Methods for follow-up research of exome analysis): 1.对突变频率.突变类型.突变方式进行统计分析 Mutati ...
- js弹出层
js弹出层 1.div附近显示 <div id="message"></div> $().delay().hide(); 2.遮罩层 表单提交后遮住页面,等 ...
- 关于苹果手机微信端 position: fixed定位top导航栏问题
在移动端,position: fixed定位一般不被识别,或者在ios系统中,获取input焦点时,会导致position: fixed的top失效,下面是我验证过的方法,大家可以试试.<!do ...
- Tree Restoration Gym - 101755F (并查集)
There is a tree of n vertices. For each vertex a list of all its successors is known (not only direc ...
- Go-day02
Go程序的基本结构 ***func init() 会在main函数之前执行 1.包中的函数调用 a.同一个包中函数,直接调用 b.不同包中函数,通过包名+点+函数名进行调用 2.包的访问控制规则 a. ...