|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
欢迎大家来到仓酷云论坛!纲目:
1、媒介
2、搭建Git办事器
- yum装置Git办事器
- 创立一个git用户,用来运转git办事
- 创立客户端登录证书
- 初始化Git堆栈
- 禁用shell登录
- 克隆近程堆栈
3、装置客户端
4、总结
注,测试机CentOS5.5x86_64,Git办事器版本:gitversion1.8.2.1,客户端版本:gitversion1.9.2.msysgit.0。一切软件请到这里下载:http://msysgit.github.io/。
1、媒介
在上一篇博客中我们次要解说Git是甚么,Git的基础道理,解说一些有关Git的基本常识,让我们复杂的懂得一下Git,固然我们另有良多成绩没有弄分明,嘿嘿!不论理怎样,在我们弄分明这些成绩之前,我们得有台Git办事器是吧,嘿嘿!好了,上面我们就来一同搭建一台Git办事器。
2、搭建Git办事器
1.yum装置Git办事器
[root@git~]#cdsrc/
[root@gitsrc]#wgethttp://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
[root@gitsrc]#rpm-ivhepel-release-5-4.noarch.rpm
Preparing...###########################################[100%]
packageepel-release-5-4.noarchisalreadyinstalled
[root@git~]#yumlist
[root@git~]#yuminstall-ygit
2.创立一个git用户,用来运转git办事
[root@git~]#addusergit
3.创立客户端登录证书
注,搜集一切必要登录的用户的公钥,就是他们本人天生的id_rsa.pub文件,把一切公钥复制到/home/git/.ssh/authorized_keys文件里,一行一个。嘿嘿!
1).客户端天生id_rsa.pub文件的下令
$ssh-keygen-trsa
$cat.ssh/id_rsa.pub
ssh-rsaAAAAB3NzaC1yc2EAAAABIwAAAQEA6NwUHeNNi+PC6KlrcJrXXDmKxRMmgHIPp79sgX6zqfdSlmNj7rBPQeyEKS9Wg8yI6jd8aG2jsUx99Vjti2VK2vEXKkRHxwID7ri69gE71RfDtv6ekafnzLo14J8hAp0spMk+N3wEAQRYDmcYo1wmnm/jMBedGrHj4NJQ1vYy1hVtJasGMSzjcMrlz9qvaluWnQ5tQjKFQVVwKsRRRzs8qTvzVhLJt4NQ+CAN45tqfsRuf58Uba9QNK7/6xSUiIKXQiILz8PMGJ3MnlV+eN3wx2aeztdevxu9plggtG05SMmd8GNVzXrN1IaxXSvz0UwjQ2kygu7aCqO8AZWH49rouw==leo@LEO-PC
注,一起回车便可,将天生的id_rsa.pub,复制给***,帮你在办事器上增添一下,下次你用git时就不必要输出用户名和暗码了。
2).检察办事器上authorized_keys文件
[root@git~]#cat/home/git/.ssh/authorized_keys
ssh-rsaAAAAB3NzaC1yc2EAAAABIwAAAQEAwMU4FKB6NRc3XSoIunWsdvVVuSoncbVb5Al6lB3ciswBVd++YmJFhqwkITNGccrO5sycROs9+Fbjgd6oBSzNuaBtCIbwNNsEyM/henTl2euI3XsnJQ/ITr6c/q0P3WoGl4E2QFQ2kZqs+1eDC0CgHcBrqvFv1Jr414sVYK9lfZwIF+jDdtaBOrSJuq1Agx9pGUFUEB4tQfkXxsWm/MvOmKAVvduKDE1eenUEL9zzyeELPcSXLe3NOoTjZhkX6EEXxQR1ZiZRFywLpfM4qopZ10to2KIUyVtzw6hx6V3cg7kn40lYVW0EAMATw9dVldwcRUI+kJzJSKUTKDVSwY3/+Q==root@CHENMINGQIAN
ssh-rsaAAAAB3NzaC1yc2EAAAABIwAAAQEAsmmJuR+KhRSpdSirCiL30RA8WbfgicY1z7itWVnKHJW6hTuJFhzruY59FilVjJR1hbQBluP9JnK3XPSK9PSg+bwiJ2iQRa39rXck35r+trVOLyNbPyfKVRfOemD8YuykMlyr5JeW8gZjsHEuLnJ8//RiCiYzd3RT/SSUQ4yawDoIIWkz3eUSL09xoCRZFBsAp+S/LD3vx2MN+FNOHwvqcE+yK3oRNIqjWwLoKE0e5TRnqNgrPQ95PJYB3XPUulzaeMwsWPZs7jIUMl/5yEqSgAkioa8SVMOsikYJG/erv99NNVgFmpCBIiWqKEGkNrIpYzLLHDSYQ4g5Gbci/RZ54Q==Administrator@WIN2003X323
ssh-rsaAAAAB3NzaC1yc2EAAAABIwAAAQEA6NwUHeNNi+PC6KlrcJrXXDmKxRMmgHIPp79sgX6zqfdSlmNj7rBPQeyEKS9Wg8yI6jd8aG2jsUx99Vjti2VK2vEXKkRHxwID7ri69gE71RfDtv6ekafnzLo14J8hAp0spMk+N3wEAQRYDmcYo1wmnm/jMBedGrHj4NJQ1vYy1hVtJasGMSzjcMrlz9qvaluWnQ5tQjKFQVVwKsRRRzs8qTvzVhLJt4NQ+CAN45tqfsRuf58Uba9QNK7/6xSUiIKXQiILz8PMGJ3MnlV+eN3wx2aeztdevxu9plggtG05SMmd8GNVzXrN1IaxXSvz0UwjQ2kygu7aCqO8AZWH49rouw==leo@LEO-PC
申明:我这里有三个用户登录办事器,以是我这里就有三个ssh-rsa,人人能够看一下。
4.初始化Git堆栈
注,先选定一个目次作为Git堆栈,这里是/data/git/project.git。
[root@git~]#cd/data/git/
[root@gitgit]#gitinit--bareproject.git
[root@gitproject.git]#ls
branchesconfigdescriptionHEADhooksindexinfoobjectsrefs
实行以上下令Git下令,会创立一个***堆栈,***堆栈没有事情区,由于办事器上的Git堆栈地道是为了同享,以是不让用户间接登录到办事器上往改事情区,而且办事器上的Git堆栈一般都以.git开头。然后,把owner改成git:
[root@gitgit]#chown-Rgit.gitproject.git
[root@gitgit]#ls-l
总计4
drwxr-xr-x7gitgit409605-0913:50project.git
5.禁用shell登录
注,出于宁静思索,第二步创立的git用户不同意登录shell,这能够经由过程编纂/etc/passwd文件完成。找到相似上面的一行:
[root@git~]#cat/etc/passwd|grepgit
git:x:1001:1001:gitversioncontrol:/home/git:/bin/bash
[root@git~]#vim/etc/passwd
git:x:1001:1001:gitversioncontrol:/home/git:/usr/bin/git-shell
如许,git用户能够一般经由过程ssh利用git,但没法登录shell,由于我们为git用户指定的git-shell每次一登录就主动加入。
6.克隆近程堆栈
注,如今能够经由过程gitclone下令克隆近程堆栈了,在各自的电脑上运转:
[code][/code]
注,$gitclonegit@git.jjhh.com:/data/git/project.git,个中git用户名,git.jjhh.com办事器,/data/git/prgject.git是堆栈路径。好了,到这里办事器的搭建到这里就完成了,上面我们来装置一下客户端。
3、装置客户端
1.Windows客户端
1).下载客户端
注,人人到这里下载http://msysgit.github.io/。上面复杂演示一下装置历程,对照复杂:
好了,到这里就装置完成了,装置好今后会在桌面上有个图标,你双击翻开便可。以下图:
2.Linux客户端
注,Linux客户端装置就对照复杂了,间接用yum装置一下就好!
1
[root@test~]#yuminstall-ygit
到这里git就装置完成了,上面我们检察一下版本:
1
2
[root@test~]#git--version
gitversion1.8.2.
上面我们天生公钥并复制到办事器上:
[root@test~]#ssh-keygen-trsa
Generatingpublic/privatersakeypair.
Enterfileinwhichtosavethekey(/root/.ssh/id_rsa):
Createddirectory/root/.ssh.
Enterpassphrase(emptyfornopassphrase):
Entersamepassphraseagain:
Youridentificationhasbeensavedin/root/.ssh/id_rsa.
Yourpublickeyhasbeensavedin/root/.ssh/id_rsa.pub.
Thekeyfingerprintis:
48:3c:22:76:02:f1:a2:e5:27:22:cb:4f:a7:a0:98:9droot@test.com
[root@test~]#cat.ssh/id_rsa.pub
ssh-rsaAAAAB3NzaC1yc2EAAAABIwAAAQEAwrmgNAca77BKzXl6BP11fdaclAoWfW+x4kPDZMPj1zFoML9JfOAS7DGY9quLMitwwfg5+U7zP/egPmAhSKCECubmodzMucnRSkJGgKCt1SlctRNDRN3OIvrecAtdZfDcBaWKLjaVzGPmhweLhr6HzfqeZU09Ccis4yK3RMwip2f+K1ZZVIOKUmL4AVFl9dqtxnQ4HlW61PUxvM/ug2M68Z0jQk5DVG8w5+dvGqX1qr5YABD1NX5Jz6aUbVVx7yyoORENxu6SK83GI/V7eOkrvBMDh9nDdwvDhPhuhBDSfE+Xi92hPJPKdNroF1vx8HMvpHME20MmjSwavPrz+B18MQ==root@test.com
上面我们复制id_rsa.pub里的公钥到办事器的authorized_keys文件中。
[root@git~]#sugit
bash-3.2$cd
bash-3.2$vim.ssh/authorized_keys
ssh-rsaAAAAB3NzaC1yc2EAAAABIwAAAQEAwMU4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05SMmd8GNVzXrN1IaxXSvz0UwjQ2kygu7aCqO8AZWH49rouw==leo@LEO-PC
ssh-rsaAAAAB3NzaC1yc2EAAAABIwAAAQEAwrmgNAca77BKzXl6BP11fdaclAoWfW+x4kPDZMPj1zFoML9JfOAS7DGY9quLMitwwfg5+U7zP/egPmAhSKCECubmodzMucnRSkJGgKCt1SlctRNDRN3OIvrecAtdZfDcBaWKLjaVzGPmhweLhr6HzfqeZU09Ccis4yK3RMwip2f+K1ZZVIOKUmL4AVFl9dqtxnQ4HlW61PUxvM/ug2M68Z0jQk5DVG8w5+dvGqX1qr5YABD1NX5Jz6aUbVVx7yyoORENxu6SK83GI/V7eOkrvBMDh9nDdwvDhPhuhBDSfE+Xi92hPJPKdNroF1vx8HMvpHME20MmjSwavPrz+B18MQ==root@test.com
上面我们clone一个堆栈到当地的目次中。
[root@test~]#cd/data/dev
[root@testdev]#gitclonegit@git.jjhh.com:/data/git/project.git
Cloningintoproject...
Theauthenticityofhostgit.jjhh.com(114.112.173.150)cantbeestablished.
RSAkeyfingerprintisca:ec:a2:7e:e6:89:ca:19:d3:93:7f:4b:c3:c0:c7:fd.
Areyousureyouwanttocontinueconnecting(yes/no)?yes
Warning:Permanentlyaddedgit.jjhh.com,114.112.173.150(RSA)tothelistofknownhosts.
remote:Countingobjects:50,done.
remote:Compressingobjects:100%(42/42),done.
remote:Total50(delta21),reused0(delta0)
Receivingobjects:100%(50/50),4.02KiB,done.
Resolvingdeltas:100%(21/21),done.
[root@testdev]#ls
project
[root@testdev]#cdproject/
[root@testproject]#ls
index.html
好了,到这里我们的git客户端到这里就全体装置完成了。
4、总结
Q&A,有甚么成绩接待人人交换会商。最初,但愿人人有所劳绩^_^……
本文出自“Shareyourknowledge…”博客,请务必保存此出处http://freeloda.blog.51cto.com/2033581/1410562
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的小伙伴们! |
|