标签:
Ubuntu12.04 LTS默认是已经安装Git的,可以使用 git --version 测试是否安装。
如果没有安装,使用命令: sudo apt-get install git git-core 安装git
官网教程: https://help.github.com/articles/generating-ssh-keys/
创建公钥 ssh key
carloz@linux:~/Downloads/usr/bin$ ls -al ~/.ssh total 16 drwx------ 2 carloz carloz 4096 10月 29 17:06 . drwxr-xr-x 42 carloz carloz 4096 10月 29 16:39 .. -rw------- 1 carloz carloz 1679 10月 29 16:44 github -rw-r--r-- 1 carloz carloz 403 10月 29 16:44 github.pub carloz@linux:~/Downloads/usr/bin$ ssh-keygen -t rsa -b 4096 -C "xiaoqing_work@163.com" Generating public/private rsa key pair. Enter file in which to save the key (/home/carloz/.ssh/id_rsa): Enter passphrase (empty for no passphrase): xiaoqing Enter same passphrase again: Your identification has been saved in /home/carloz/.ssh/id_rsa. Your public key has been saved in /home/carloz/.ssh/id_rsa.pub. The key fingerprint is: 66:b5:f4:85:37:4c:c1:7e:bf:d3:bd:c1:7a:d7:2d:f5 xiaoqing_work@163.com The key‘s randomart image is: +--[ RSA 4096]----+ | .o. | | +. | | o ..= | | o o o...| | S . . ..| | o . o| | +B| | o+E| | ..o+| +-----------------+ carloz@linux:~/Downloads/usr/bin$
复制公钥
carloz@linux:~/Downloads/usr/bin$ ls -al ~/.ssh total 24 drwx------ 2 carloz carloz 4096 10月 29 17:12 . drwxr-xr-x 42 carloz carloz 4096 10月 29 16:39 .. -rw------- 1 carloz carloz 1679 10月 29 16:44 github -rw-r--r-- 1 carloz carloz 403 10月 29 16:44 github.pub -rw------- 1 carloz carloz 3326 10月 29 17:12 id_rsa -rw-r--r-- 1 carloz carloz 747 10月 29 17:12 id_rsa.pub carloz@linux:~/Downloads/usr/bin$ vi ~/.ssh/id_rsa.pub carloz@linux:~/Downloads/usr/bin$ eval "$(ssh-agent -s)" Agent pid 8644 carloz@linux:~/Downloads/usr/bin$ ssh-add ~/.ssh/id_rsa Enter passphrase for /home/carloz/.ssh/id_rsa: xiaoqing Identity added: /home/carloz/.ssh/id_rsa (/home/carloz/.ssh/id_rsa) carloz@linux:~/Downloads/usr/bin$ sudo apt-get install xclip carloz@linux:~/Downloads/usr/bin$ xclip -sel clip < ~/.ssh/id_rsa.pub
添加key到github
连接 github
carloz@linux:~/Downloads/usr/bin$ rm ~/.ssh/git* carloz@linux:~/Downloads/usr/bin$ ls -al ~/.ssh total 16 drwx------ 2 carloz carloz 4096 10月 29 17:23 . drwxr-xr-x 42 carloz carloz 4096 10月 29 16:39 .. -rw------- 1 carloz carloz 3326 10月 29 17:12 id_rsa -rw-r--r-- 1 carloz carloz 747 10月 29 17:12 id_rsa.pub
carloz@linux:~/Downloads/usr/bin$ ssh -T git@github.com The authenticity of host ‘github.com (192.30.252.129)‘ 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.129‘ (RSA) to the list of known hosts. Hi carlo-z! You‘ve successfully authenticated, but GitHub does not provide shell access. carloz@linux:~/Downloads/usr/bin$
标签:
原文地址:http://www.cnblogs.com/carlo/p/4921074.html