在 Mac OS X 上关联 GitHub 2014-12-10 / 1,794 次 / 快抢沙发 /

摘要:本地的工程关联 GitHub ,我们需要通过 SSH Key 验证。

Runtime Environment
OS: Mac OS X 10.9.2
JDK: 1.6.0
Git: 1.8.5.2 (Apple Git-48)
SourceTree: 2.0.2
如果你想要在 GitHub 上创建自己的项目,并且希望在本地电脑上开发项目并且上传至 GitHub ,那么你需要知道如何关联 GitHub !
1.你需要下载安装:
SourceTree (可视化 Git 管理软件) http://www.sourcetreeapp.com
Git http://www.git-scm.com
备注:你不一定需要下载 Git,SourceTree 自带 Git。
2.打开命令行,进入到 .ssh 文件夹,查看是否已经存在 id_rsa 和 id_rsa.pub 两个文件:

Last login: Tue Dec  9 06:05:14 on console
ifeegoo:~ ifeegoo$ cd .ssh
ifeegoo:.ssh ifeegoo$ ls
known_hosts
2.如果在 .ssh 文件夹中不存在 id_rsa 和 id_rsa.pub 两个文件,用命令 ssh-keygen -t rsa -C “GitHub 上注册的邮件地址” 来创建RSA key:

ifeegoo:.ssh ifeegoo$ ssh-keygen -t rsa -C root@ifeegoo.com
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/ifeegoo/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/ifeegoo/.ssh/id_rsa.
Your public key has been saved in /Users/ifeegoo/.ssh/id_rsa.pub.
The key fingerprint is:
f3:5e:61:e6:6f:f8:db:56:dc:ca:ac:b1:c5:ca:12:65 root@ifeegoo.com
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|                 |
|            E    |
|        S  o+  ..|
|         o.+ o  +|
|          ..++o..|
|         ..o.*=..|
|          ..=++o.|
+-----------------+
3.如果在 .ssh 文件夹中已经存在 id_rsa 和 id_rsa.pub 两个文件:打开 id_rsa.pub ,复制其中的内容。

ifeegoo:.ssh ifeegoo$ ls
id_rsa		id_rsa.pub	known_hosts
ifeegoo:.ssh ifeegoo$ cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCnBGAUbxPKnNM19wr5qHRQsiupewPBXdqoTdNGeEA7u0iiRu+ZsVl86HkLn+xPfk6SE9zppusOoN7ALVy8OhhGdq4kSbB4MVqmxHVaAKWW3iQkPRuNxHHg5Nj8NLBxpVE+gnY+PsAN7b7+iocgcaqe3qCKBy2CwguKIZQNpe67k5CMvgT1BM82ngZPk7LCD7ji1Lna/ufUE0W1rPBc1qF11ljINOKGVarh9+rU6XsWaMnxwcOyHn+iNFWv2DJZ9Bqvb3bvVrRYwFxdQUEf1Cx/WNSX2WKg1HgE2/XTkDDZ9ahJV1aZdLoTpRm/q9KHfFxMVNVTSW2aBGz8aRZ3iqgv root@ifeegoo.com
4.登陆 GitHub ,进入 Settings → SSH Keys:将 id_rsa.pub 中的内容填入 Key 下面的输入框,Title 任意填写,然后保存。
github-settings-ssh-keys-add-ssh-key
5.在终端中使用命令行来验证SSH Key 是否关联上:

ifeegoo:.ssh ifeegoo$ ssh git@github.com
The authenticity of host 'github.com (192.30.252.128)' 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
Warning: Permanently added 'github.com,192.30.252.128' (RSA) to the list of known hosts.
PTY allocation request failed on channel 0
Hi ifeegoo! You've successfully authenticated, but GitHub does not provide shell access.
Connection to github.com closed.
6.如果出现 “You’ve successfully authenticated”,就表明你此次关联 SSH Key 成功,然后你就可以通过 SourceTree 在 GitHub 上将本地的工程上传和管理了!
打赏
本博客所有文章如无特别注明均为原创。复制或转载请以超链接形式注明转自ifeegoo的个人博客,原文地址《在 Mac OS X 上关联 GitHub
上一篇: « 下一篇: »
暂无相关文章

> 添加新评论