自己创建git服务器,也不是第一次。但是很少,结果又出错了。
.ssh/config: line 2: Bad configuration option: host:106.xx.xx.35
.ssh/config: terminating, 1 bad configuration options
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
反反复复回头,特别是注意权限设置需要修改?
git:x:502:502::/home/git:/bin/bash
git:x:502:502::/home/git:/usr/local/git/bin/git-shell
不能够一开始就改还是改成1000而不是502?因为一改就不能够加入公钥?但是root用户也可以吧?所以可能不需要在意。
https://www.cnblogs.com/mverting/p/10206532.html
四. 配置git
Git服务器打开RSA认证
vi /etc/ssh/sshd_config #以下项前面的#去掉
1.RSAAuthentication yes
2.PubkeyAuthentication yes
3.AuthorizedKeysFile .ssh/authorized_keys禁止Shell登录
vi /etc/passwd
git:x:502:502::/home/git:/bin/bash 修改成下面的 git的路径要设置成自己的
git:x:502:502::/home/git:/usr/local/git/bin/git-shell创建git用户组和用户
groupadd git
useradd git -g git
passwd git
su - git #切换到刚创建的git用户创建用户公钥文件
cd /home/git/
mkdir .ssh #新建文件夹
chmod 700 .ssh
touch .ssh/authorized_keys #新建文件
chmod 600 .ssh/authorized_keys
后续用户只需要向authorized_keys中添加自己的公钥五. 创建仓库及使用
1. cd /home/git #在某个文件夹下创建
git init --bare test.git #创建一个空仓库 仓库名字叫 test2. 本地克隆仓库 git clone git@your-ip:test.git
最后什么问题?
因为我的config格式出错了:
网友说不能够有缩进,我没有,但是……阿里云说注意字符格式代码……一看:host一栏多了个冒号,本来是空格。