搭建自己的git服务器
自己有一个学生云服务器,闲置没有用处,想着以后会有实验室或者多个电脑终端的文件共享问题,可以通过搭建自己的git服务器解决,于是动手开干。
1 – 环境
- 阿里云云翼计划学生云服务器一台
- ubunto 16.04系统
2 – 步骤
2.1 – 安装git
sudo apt-get install git-core
2.2 – 开启ssh服务
通过下面命令查看系统是否已经开启了ssh服务。
ps -ef|grep sshd
如果没有则通过下面命令安装。
sudo apt-get install openssh-server openssh-client
2.3 – 创建git服务器管理用户
sudo useradd XXX(创建名称为XXX的用户)
sudo passwd XXX(XXX用户对应的密码也是XXX)
2.4 – 创建git仓库存储目录和权限
sudo mkdir /home/git/repositories sudo chown git:git /home/git/repositories sudo chmod 755 /home/git/repositories
2.5 – 切换到git用户并建立服务器仓库
su git cd /home/git/repositories git init --bare XXX.git //初始化一个仓库名称为XXX的仓库
3 – 遇到问题及解决方法
问题:ssh登录错误:WARNING: REMOTE HOST IDENTIFICATION HAS CHANDED!
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the ECDSA key sent by the remote host is SHA256:Bj7pcWrxXjF/l83VzISKJoVIR3sVIW7BW0Br9eheCPY. Please contact your system administrator. Add correct host key in /c/Users/PC/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /c/Users/PC/.ssh/known_hosts:3 ECDSA host key for 47.107.57.184 has changed and you have requested strict checking. Host key verification failed. fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
解决方法:
- 在客户端执行下面命令(windows直接找到known_hosts文件修改即可,一般在路径C:\Users\PC\.ssh)
- 删除里面对应服务器IP的内容即可
vi ~/.ssh/known_hosts
4 – 参考资料
https://blog.csdn.net/zhuxiaoping54532/article/details/53813437