第一步 生产秘钥
lvyuebindeMacBook-Pro:~ lvyuebin$ ssh-keygen -t rsa -C "lvyuebin@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/lvyuebin/.ssh/id_rsa): lvyuebin // 这里输入秘钥文件名称
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in lvyuebin.
Your public key has been saved in lvyuebin.pub.
The key fingerprint is:
SHA256:20gmQbrVtTpD0WXuiiccaOiCAmf7VRJK5hVe+M/QXcE lvyuebin@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| o.o...o... |
| +.+ o.+ E |
| + *.o..... |
| + * =o.... |
|. o = = S+ . |
|.+ o . B Oo. |
|o o . . * + |
|. o . o |
| . |
+----[SHA256]-----+
生成完了后,需要查看来秘钥内容,这样就可以放到oschina,秘钥路径就是上面,当然可以ls下看看文件在不在。查看命令如下:
cat ~/.ssh/lvyuebin.pub
复制秘钥内容后,打开oschina后台添加一个秘钥,拷贝,保存,输入密码。ps:oschina还会给你发送个邮件
下面继续输入添加链接命令:
ssh-add ~/lvyuebin
正确的返回:Identity added: lvyuebin (lvyuebin)
lvyuebindeMacBook-Pro:~ lvyuebin$ ssh -T git@git.oschina.net
The authenticity of host 'git.oschina.net (180.97.163.93)' can't be established.
ECDSA key fingerprint is SHA256:FQGC9Kn/eye1W8icdBgrQp+KkGYoFgbVr17bmjey0Wc.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'git.oschina.net,180.97.163.93' (ECDSA) to the list of known hosts.
Welcome to Git@OSC, 大腿哥!
链接完事!下面就可以用了,提交本地用xcode commit,提交到git上用push。
设置git的名称和email,默认好像名字是git
git config –-global user.name "lvyuebin"
git config –-global user.email lvyuebin@msn.cn
获取git@osc 上的项目路径。
输入命令:cd 项目文件夹
输入命令:git remote add origin git@git.oschina.net:datuige/base.git
输入命令:git pull -u origin master //从git@osc 上拉取项目
输入命令:git push -u origin master //提交项目