git生成ssh key
2015-09-10 12:35
337 查看
步骤
检查SSH keys是否存在生成新的ssh key
将ssh key添加到GitHub中
1. 检查SSH keys是否存在
输入下面的命令,如果有文件id_rsa.pub或
id_dsa.pub,则直接进入步骤3将SSH
key添加到GitHub中,否则进入第二步生成SSH key
ls -al ~/.ssh # Lists the files in your .ssh directory, if they exist
2. 生成新的ssh key
第一步:生成public/private rsa key pair在命令行中输入
ssh-keygen -t rsa -C "your_email@example.com"
默认会在相应路径下(/your_home_path)生成
id_rsa和
id_rsa.pub两个文件,如下面代码所示
ssh-keygen -t rsa -C "your_email@example.com" # Creates a new ssh key using the provided email Generating public/private rsa key pair. Enter file in which to save the key (/your_home_path/.ssh/id_rsa):
第二步:输入passphrase(本步骤可以跳过)
设置passphrase后,进行版本控制时,每次与GitHub通信都会要求输入passphrase,以避免某些“失误”
Enter passphrase (empty for no passphrase): [Type a passphrase] Enter same passphrase again: [Type passphrase again]
sample result:
Your identification has been saved in /your_home_path/.ssh/id_rsa. Your public key has been saved in /your_home_path/.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中:
# start the ssh-agent in the background eval "$(ssh-agent -s)" Agent pid 59566 ssh-add ~/.ssh/id_rsa
3. 将ssh key添加到GitHub中
用自己喜欢的文本编辑器打开id_rsa.pub文件,里面的信息即为SSH key,将这些信息复制到GitHub的
Add SSH key页面即可
相关文章推荐
- 【unity插件】Tiled2Unity-非常方便的将Tiled导入到unity3d
- 通过ServiceLoader实现链式处理
- PHP安装redis扩展
- 模糊匹配字符的正则表达式+例子
- 360酷派之争升级 ,“关键人”为何保持缄默?
- ThreadLocal使用
- Win10 Mobile预览版10536升级更新截图曝光:版本号10.0.10536.1003
- javascript----显示日期
- 孙陪你,了解它的力量——unity3d流程暂停
- SysLog简介和java操作实例
- iOS TableView和TableViewCell的风格
- LVS-DR模型简介
- storm-start项目示例和开发-03.docx
- 谷歌回归前景堪忧:狼真来了却落入虎口
- Desktops 虚拟桌面软件(推荐)
- android jni 有感一
- 比较好的js框架和代码学习网站
- ERROR: JDWP Transport dt_socket failed to initialize, TRANSPORT_INIT(510)
- AIDL Android
- http://www.cnblogs.com/huangcong/archive/2010/06/14/1757957.html