centOS 安装git 私服
时间: 2023-11-28 10:43:48 浏览: 91
以下是在CentOS上安装Git私服的步骤:
1. 安装Git
```shell
yum install git
```
2. 创建Git用户
```shell
useradd git
```
3. 创建Git仓库
```shell
mkdir /home/gitrepo
chown git:git /home/gitrepo
cd /home/gitrepo
git init --bare runoob.git
```
4. 配置SSH
```shell
vi /etc/ssh/sshd_config
```
找到以下两行,去掉注释并修改为:
```shell
RSAAuthentication yes
PubkeyAuthentication yes
```
重启SSH服务:
```shell
systemctl restart sshd
```
5. 添加SSH公钥
将客户端的公钥添加到Git服务器的authorized_keys文件中:
```shell
su - git
mkdir ~/.ssh
touch ~/.ssh/authorized_keys
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
vi ~/.ssh/authorized_keys
```
将客户端的公钥复制到authorized_keys文件中并保存。
6. 测试连接
在客户端上执行以下命令:
```shell
ssh git@your_server_ip
```
如果连接成功,则说明Git私服已经安装成功。
阅读全文
相关推荐















