参考:https://www.unixhot.com/article/33 git
在腾讯软件中心下载了git、TortoiseGit-2.10.0.0-64bit(原来在官网总下载到一半就没反应了)docker
简单安装后首先在gitbash里生成密钥(实现ssh免密码登陆)bash
配置用户名
服务器
git config --global user.name "a11"app
配置邮箱ssh
git config --global user.email "992668717@qq.com"ide
生成密钥对测试
ssh-keygen -t rsa -C "992668717@qq.com"unix
复制公钥到服务器的authorized_keysip
cat ~/.ssh/id_rsa.pub
docker exec -it 398558f43910 /bin/sh (进入git容器)
vi ./.ssh/authorized_keys
git客户端使用
git clone git@172.27.14.222:/home/git/sample.git
git init
git remote add origin git@172.27.14.222:/home/git
git push -u origin master
问题:
测试克隆git上的目录总报没权限
git clone git@172.27.14.222:30813/home/git/sample.git
Cloning into 'sample'...
The authenticity of host '172.27.14.222 (172.27.14.222)' can't be established.
ECDSA key fingerprint is SHA256:FR1kBUsCE1Ng4hJFX6zt8nKZY8UKsU+LG0LU2mro2X0.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.27.14.222' (ECDSA) to the list of known hosts.
git@172.27.14.222's password:
Permission denied, please try again.
git@172.27.14.222's password:
Connection closed by 172.27.14.222 port 22
fatal: Could not read from remote repository.
原来对于服务器ssh非默认端口须要增长~/.ssh/config文件以下内容
Host:172.27.14.222
Port:30813
git clone git@172.27.14.222:/home/git/sample.git
Cloning into 'sample'...
The authenticity of host '[172.27.14.222]:30813 ([172.27.14.222]:30813)' can't be established.
ECDSA key fingerprint is SHA256:+NnZdk+KT0ipBcEJW65ryULNklH/Mb0L00hRVJhC8aQ.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '[172.27.14.222]:30813' (ECDSA) to the list of known hosts.
warning: You appear to have cloned an empty repository.