git下添加新项目及用户

我们在上一节(http://blog.haohtml.com/archives/12658)配置成功了git-server。这里我们新创建一个git项目并允许开者使用.

1. 生成密钥与公钥

[dev1@bogon ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/dev1/.ssh/id_rsa):
Created directory ‘/home/dev1/.ssh’.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/dev1/.ssh/id_rsa.
Your public key has been saved in /home/dev1/.ssh/id_rsa.pub.
The key fingerprint is:
99:4c:e4:00:56:a9:a2:e2:68:20:8c:60:90:2e:b9:b8 dev1@bogon
The key’s randomart image is:
+–[ RSA 2048]—-+
| . ooo.. |
|o . .+ |
|o. . o |
|+o. . o o |
|Bo . S |
|O. |
|*. |
|Eo |
|. |
+—————–+

[dev1@bogon ~]$ ls .ssh
id_rsa id_rsa.pub

2.将公钥上传到git server的gitosis-admin/keydir/ 目录里,文件名就是是用户名(这里文件名必须与客户端的用户名一致,否则无法使用.不知道同名的情况下如何处理?)
注意:我这里是在同一台机器上测试的,不同的机器可以用scp命令来实现上传文件,主要pub文件上传到keydir目录下才可以(scp ~/.ssh/id_rsa.pub root@192.168.0.77:/tmp/sxf.pub) 

cd /root/gitosis-admin/keydir/
cp /home/dev1/.ssh/id_rsa.pub ./dev1.pub

3.创建新项目,将dev1用户添加进去

cd /home/gitosis-admin/

vi gitosis.conf
[group project2]
writable = project2
members = dev1

4.保存修改,并将修改提交到git server上

git add .
git commit -a -m ‘add new user dev1’
git push

5.在客户端测试(用户为dev1)
创建项目project2目录(一定要和项目名称一样)

mkdir /data/project2
cd /data/project2
git init
touch test.txt
git add .

git config –global user.email “you@example.com”
git config –global user.name “Your Name”

git commit -a -m ‘init project2’
git remote add origin git@xxx:project2.git
git push origin master

git pull

可以看到已经提交成功了!

如果客户端为Linux的话,在执行git pull的时候,出现

 Permissions 0644 for ‘/root/.ssh/id_rsa’ are too open.

等错误显示了,只要把权限降到0600就ok了.这种情况下一般是属于将另其它地方的公钥直接放在其它客户端用的原因。

输入命令

chmod 0600 ~/.ssh/id_rsa

然后再执行相应的命令即可.这样就可以密钥登陆了.

相关教程:
git remote 常用命令总结

42 thoughts on “git下添加新项目及用户

  1. Pingback: CentOS下搭建Git服务器Gitosis | haohtml's blog

  2. Pingback: CentOS下搭建Git服务器Gitosis | @黄天佩

  3. Pingback: Enigma Review

  4. Pingback: lose weight naturally

  5. Pingback: https://fotografia-anetaden.pl/

  6. Pingback: 온라인카지노

  7. Pingback: 카지노사이트

  8. Pingback: w88th

  9. Pingback: https://surfwearhawaii.com

  10. Pingback: i99bet

  11. Pingback: santali film single

  12. Pingback: Eddie Frenay

  13. Pingback: vào w88

  14. Pingback: tag heuer grand carrera replica

  15. Pingback: removable dance floor decals

  16. Pingback: Bali,Indonesia

  17. Pingback: Polished Concrete Floors

  18. Pingback: imitation wholesale rolex

  19. Pingback: https://sportzdrowie.com.pl/forum/zele-masci-plastry-f15/paski-crest-pl-opinie-t408.html

  20. Pingback: 온라인카지노

  21. Pingback: 안전놀이터

  22. Pingback: satta king

  23. Pingback: 바카라 사이트 신고

  24. Pingback: 토토사이트

  25. Pingback: http://funkymedia-opinie.pl/

  26. Pingback: link vaom88

  27. Pingback: Buy Vyvanse Online

  28. Pingback: Jelle Hoffenaar

  29. Pingback: Best Travel tips and articles

  30. Pingback: Cvv Dumps Shop - Buy Dumps with Pin , Cvv Good balance

  31. Pingback: 7lab pharma winstrol for sale

  32. Pingback: iOS programming

  33. Pingback: richard mille replica ioffer

  34. Pingback: cannes ladies designer watches fake diamonds gold coler

  35. Pingback: generic viagra 100mg pills erections

  36. Pingback: Free CBD OIL

  37. Pingback: Juul Pods for sale

  38. Pingback: replica tag automatic

  39. Pingback: buy hydroxychloroquine online

  40. Pingback: Aaron

  41. Pingback: yourastrologyguru.com

  42. Pingback: 7lab pharma trenbolone 200

Comments are closed.