GitHub创建SSH Keys
来源:互联网 发布:淘宝司法拍卖怎么样 编辑:程序博客网 时间:2024/04/30 15:28
如何生成SSH key
如何生成SSH key
SSH key提供了一种与GitHub通信的方式,通过这种方式,能够在不输入密码的情况下,将GitHub作为自己的remote端服务器,进行版本控制
步骤
- 检查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 emailGenerating 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 backgroundeval "$(ssh-agent -s)"Agent pid 59566ssh-add ~/.ssh/id_rsa
3. 将ssh key添加到GitHub中
用自己喜欢的文本编辑器打开id_rsa.pub
文件,里面的信息即为SSH key,将这些信息复制到GitHub的Add SSH key
页面即可
不同的操作系统,均有一些命令,直接将SSH key从文件拷贝到粘贴板中,如下:
mac
pbcopy < ~/.ssh/id_rsa.pub# Copies the contents of the id_rsa.pub file to your clipboard
windows
clip < ~/.ssh/id_rsa.pub# Copies the contents of the id_rsa.pub file to your clipboard
linux
sudo apt-get install xclip# Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)xclip -sel clip < ~/.ssh/id_rsa.pub# Copies the contents of the id_rsa.pub file to your clipboard
本文首载于Gevin's blog
====================================================
第一步:在用户主目录下,看有没有.ssh目录,如果有,再看看这个目录下
有没有id_rsa和id_rsa.pub这两个文件,如果已经有了,可直接跳到下一步,如果没有
打开Git Bash,创建SSH Key
- $ ssh-keygen -t rsa -C "youremail@xxx.com"
如果一切顺利,可以在用户目录里找到.ssh目录 里面有id_rsa和id_rsa.pub两个文件
这两个就是SSH Key的秘钥,id_rsa是私钥,id_rsa.pub是公钥。
第二步:登录GitHub 打开Settings,添加Key 如图
点"Add SSH Key",填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容:
成功之后,你就能看到添加的Key
作者:itmyhome
出处:http://blog.csdn.net/itmyhome1990/article/details/39668349
- GitHub创建SSH Keys
- GitHub创建SSH Keys
- GitHub创建SSH Keys
- GitHub创建SSH Keys
- GitHub帮助:创建SSH Keys
- github添加SSH keys
- github添加ssh keys
- gitHub 配置SSH Keys
- github添加ssh keys
- Generating SSH keys for github
- github帐号添加SSH keys
- Github 配置SSH keys教程
- Generating SSH keys for github
- GitHub第一步--生成ssh keys
- Git中创建SSH Keys
- 如何创建SSH Keys(Git)
- 为github帐号添加SSH keys
- [转载]为github帐号添加SSH keys
- dos2unix命令将dos文件转换为unix格式
- 访问chrome摄像头报错
- 第24节--聚类之K-means算法(上)
- Android App 沉浸式状态栏解决方案
- windows下 composer常见错误及处理。
- GitHub创建SSH Keys
- javascript求点的凸集/凸包
- 基础语法(1)
- 微信小程序目录结构、事件处理、网络请求
- Android LitePal实战应用
- Python3 的 QT5 开发基本功
- 三种九九乘法表的使用方法
- 利用JAVA反射机制破坏单例机制,生成非单例对象
- 擒贼先擒王