首页 技术 正文
技术 2022年11月15日
0 收藏 336 点赞 4,587 浏览 1156 个字

git的服务器搭建,如果无需权限控制,仅团队内部使用,初始化一个服务器仓库,其他人通过ssh访问这个文件夹即可。如需复杂的管理,建议使用gitlab

yum install git -yid git
useradd gitsu git
cd
mkdir .ssh && chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
cat /tmp/id_rsa.john.pub >> ~/.ssh/authorized_keysmkdir -p /opt/git/repo.git
git init --bare /opt/git/repo.git
chown -R git:git /opt/gitcat /etc/shells # see if `git-shell` is already in there. If not...
which git-shell # make sure git-shell is installed on your system.
vim /etc/shells # and add the path to git-shell from last command
chsh git # and enter the path to git-shell, usually: /usr/bin/gitshellgit clone git@ip:/opt/git/repo.git

使用ssh -T git@ip 会看到一个提示

fatal: Interactive git shell is not enabled.
hint: ~/git-shell-commands should exist and have read and execute access.

下面我们可定制欢迎信息,可通过git help shell查看到帮助。

创建文件 /home/git/git-shell-commands/no-interactive-login

内容如下:

#!/bin/sh
printf '%s\n' "Hi $USER! You've successfully authenticated, but I do not"
printf '%s\n' "provide interactive shell access."
exit 128

配置权限:

chmod 500 /home/git -R
chown git:git /home/git -R

再使用ssh -T git@ip ,提示会显示欢迎信息:

Hi git! You've successfully authenticated, but I do not
provide interactive shell access.

参考:

https://www.cnblogs.com/dee0912/p/5815267.html

https://git-scm.com/book/zh/v2 – 服务器上的git

git help shell

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,903
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,429
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,245
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,057
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,689
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,726