标签:lsh attr ica git仓库 dir auth ide known systemctl
1.安装 yum install git
2.增加用户 useradd git -d /home/git -g git
3.查看公钥鉴权文件是否存在 cat /home/git/.ssh/authorized_keys
4.不存在的话,新建
cd /home/git/
mkdir .ssh
chmod 755 .ssh
touch .ssh/authorized_keys
chmod 644 .ssh/authorized_keys
5.生成一个密钥对
ssh-keygen -t rsa -C "fallshum"
是否输入密码,默认,一路Enter往下走就行
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
1d:f1:b6:c9:42:2b:ab:1d:43:5a:72:fc:31:aa:38:9d fallshum
The key‘s randomart image is:
+--[ RSA 2048]----+
| . |
| o |
| o o |
| . o = o |
| . S * + |
| * = + |
| ...= . |
| ..E+ o |
| ..o . |
+-----------------+
5.1 把生成的公钥写入/home/git/.ssh/authorized_keys
,
cat /root/.ssh/id_rsa.pub >> /home/git/.ssh/authorized_keys
查看 cat /home/git/.ssh/authorized_keys
5.2
把私钥放到客户端的.ssh目录下,先获取刚才生成的私钥
cat /root/.ssh/id_rsa
复制出来放到本地客户端
6.初始化Git仓库 修改所有者
cd /home/git/
git init --bare fallshum.git
chown -R git:git fallshum.git/
客户端打开Git Bash,clone服务端仓库
git clone git@192.168.1.1:/home/git/fallshum.git
只要看到Checking connectivity... done
就说明OK了
------------------------------------------------------------------------
遇到的问题 1:
The authenticity of host ‘IP‘ can‘t be established:
解决
https://yq.aliyun.com/articles/288093
ssh -o StrictHostKeyChecking=no username@47.95.xxx.xxx
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
修改好配置后,重新启动sshd服务即可,命令为:/etc/init.d/sshd restart (或 systemctl restart sshd )
当然,这是内网中非常信任的服务器之间的ssh连接,所以不考虑安全问题,就直接去掉了主机密钥(host key)的检查。
2.
标签:lsh attr ica git仓库 dir auth ide known systemctl
原文地址:https://www.cnblogs.com/tongbiao/p/9569126.html