git 的使用(1)-linux上的配置
Ubuntu Linux 下 git 的创建和配置1. 创建github 账号:网站: https://github.com/账号密码自己填。Ok。2. 进入Ubuntu命令编辑器。1)生成SSH keysssh-keygen -t rsa -C "yangyi@sina.cn"root@yangyi:~# ssh-keygen -t rsa
Ubuntu Linux 下 git 的创建和配置
1. 创建github 账号:
账号密码自己填。Ok。
2. 进入Ubuntu命令编辑器。
1)生成SSH keys
ssh-keygen -t rsa -C "yangyi@sina.cn"
root@yangyi:~# ssh-keygen -t rsa -C 'yangyi@sina.cn' #这里填你的注册邮箱
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa): #回车就可以,默认的路径
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase): #输入密码,不一定要是注册密码
Enter same passphrase again: #重复输入密码,看不见的
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
a0:95:33:24:26:ca:b7:ed:c2:95:97:48:d4:e9:4f:89 yangyi@sina.cn
The key's randomart image is:
+--[ RSA 2048]----+
| . o.o . |
|.. o.o + |
|.. . .B . . |
| . +ooE.o |
| ..= oS |
| . o . . |
| o . |
| . |
| |
+-----------------+
root@yangyi:~#
2)复制key 到github网站
打开,刚才生成的密钥:
全部复制,进入github 网站,点击Account settings
点击SSH keys
Add SSH key
输入,刚才复制的密钥,到key 框中,title 随便填就可以了。
点击 Add key ,会跳转到确认密码页面:
Confirm password 即可。
Ok .ssh key 添加完成:
3) 密钥验证
ssh -T git@github.com
输入
yes
即可。
root@yangyi:~# ssh -T git@github.com
The authenticity of host 'github.com (204.232.175.90)' 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 #输入yes
Warning: Permanently added 'github.com,204.232.175.90' (RSA) to the list of known hosts.
Enter passphrase for key '/root/.ssh/id_rsa': #输入创建密钥时的密码。
Hi iyangyi! You've successfully authenticated, but GitHub does not provide shell access.
# 出现这一句,代码验证成功。
3. 安装git
Ubuntu 安装git 很简单:
yangyi@yangyi:~$ sudo apt-get install git # 自动安装好了就可以了。
4. 配置邮箱和用户名:
https://help.github.com/articles/set-up-git#platform-linux
yangyi@yangyi:~$ git config --global user.name 'yangyi'
yangyi@yangyi:~$ git config --global user.email 'yangyi@sina.cn'
yangyi@yangyi:~$ git init
Initialized empty Git repository in /home/yangyi/.git/
Ok 安装和配置完毕。
更多推荐
所有评论(0)