centos 安装git私服
时间: 2023-11-27 07:46:35 浏览: 31
以下是在CentOS上安装Git私服的步骤:
1. 安装Git
```shell
yum install git
```
2. 创建Git用户
```shell
useradd git
```
3. 创建Git仓库
```shell
mkdir /home/git/repositories
cd /home/git/repositories
git init --bare test.git
```
4. 修改Git仓库所属用户
```shell
chown -R git:git test.git
```
5. 配置SSH
在客户端上生成SSH密钥:
```shell
ssh-keygen -t rsa -C "your_email@example.com"
```
将公钥添加到Git服务器:
```shell
su git
cd ~
mkdir .ssh
touch .ssh/authorized_keys
chmod 700 .ssh
chmod 600 .ssh/authorized_keys
cat id_rsa.pub >> .ssh/authorized_keys
```
6. 测试连接
在客户端上测试连接:
```shell
ssh git@your_server_ip
```
如果连接成功,会显示Git私服的欢迎信息。
相关问题
centOS 安装git 私服
以下是在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私服已经安装成功。
CentOS安装git
在CentOS系统中安装Git,你可以按照以下步骤操作:
1. **打开终端:**首先,你需要通过终端访问你的CentOS系统,可以通过SSH连接或者直接登录到服务器。
2. **更新包列表:**确保你的系统是最新的,运行命令:
```
sudo yum update -y
```
3. **安装Git:**使用`yum`包管理器安装Git,输入:
```
sudo yum install git -y
```
或者如果使用的是Docker或者其他非YUM包管理的发行版,可能需要使用`apt-get`或`apt`,例如对于Debian系列:
```
sudo apt-get install git -y
```
4. **检查安装:**安装完成后,你可以通过运行`git --version`来验证Git是否已经成功安装,显示版本号即表示安装完成。
5. **设置SSH别名(可选):**为了更方便地使用Git进行远程克隆和推送,可以设置SSH key,按照官方文档进行配置:https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent