centos搭建简易git仓库以及win11下部分git功能

157 阅读1分钟

SwitcHosts配置远程hosts链接

gitlab.com/ineo6/hosts…

CentoOs搭建低消耗Git Remote

安装教程

#安装 Git 和 OpenSSH
sudo yum install git
sudo yum install openssh-server
​
#创建 Git 用户
sudo adduser git
sudo passwd git
​
#配置 SSH 访问
sudo systemctl start sshd
sudo systemctl enable sshd
​
#创建 Git 仓库
sudo su - git
mkdir -p /home/git/myrepo.git
cd /home/git/myrepo.git
git init --bare
​
#设置仓库权限
chown -R git:git /home/git/myrepo.git
​
#配置 SSH 密钥
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
cat ~/.ssh/id_rsa.pub | ssh git@<server-ip> 'cat >> ~/.ssh/authorized_keys'#克隆仓库
git clone ssh://git@<server-ip>/home/git/myrepo.git

win11配置多public key

.ssh目录创建config文件,不能带任何后缀名,推荐用vscode创建

# GitHub configuration
Host github.com
  HostName github.com
  PreferredAuthentications publickey
  IdentityFile ~/.ssh/github_rsa
  User your-github-username
​
Host dalao666.online
  HostName dalao666.online
  PreferredAuthentications publickey
  User root
  IdentityFile C:\Users\<UserName>\.ssh\id_rsa