安装Git
一个全新的ubunt系统,需要安装Git(系统是不具有该工具的),方法如下:
在terminel中输入如下命令:
sudo apt-get install git git-core git-gui git-doc git-svn git-cvs gitweb gitk git-email git-daemon-run git-el git-arch
接下来需要检查SSH
因为GitHub会用到SSH,因此需要在shell里检查是否可以连接到GitHub
ssh -T [email protected]
如果看到:
Warning: Permanently added ‘github.com,204.232.175.90’ (RSA) to the list of known hosts.
Permission denied (publickey).
则说明可以连接。
这里假设你已经就有了GitHub用户(如果没有,需要去注册GitHub)
安装SSH keys(一定要在~/.ssh目录下操作)
在安装GitHub之前,需要先安装SSH keys
第一步:检查是否已井具有ssh keys,如果已经具有,则进行第二步,否则,进行第三步
cd ~/.ssh
ls
第二步:执行如下命令(不具有ssh keys时):
qunzhupu$ ssh-keygen -t rsa -C "[email protected]"
得到结果如下:
qunzhudeMacBook-Air:~ qunzhupu$ ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/qunzhupu/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/qunzhupu/.ssh/id_rsa.
Your public key has been saved in /Users/qunzhupu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:Rrae8DPfiAIy/KbxJrwBILPH4kkRkklMMxJAeP6LrqA [email protected]
The key's randomart image is:
+---[RSA 2048]----+
|%@ |
|*.= |
|++ o |
|o+o o . |
|+oo. . S |
|o+= o = . |
|.+o= o * |
|o ++= . = o |
|Eo+*. .. o . |
+----[SHA256]-----+
第三步:将刚刚创建的ssh keys添加到github中
- 利用gedit/cat命令,查看id_rsa.pub的内容
- 在GitHub中,依次点击Settings -> SSH Keys -> Add SSH Key,将id_rsa.pub文件中的字符串复制进去,注意字符串中没有换行和空格。
第五步:再次检查SSH连接情况(在~/.ssh目录下):
输入如下命令:
ssh -T [email protected]
如果看到如下所示,则表示添加成功:
Hi 你的用户名! You’ve successfully authenticated, but GitHub does not provide shell access.
此时,发现github上已有了SSH keys