參考:https://www.unixhot.com/article/33
在騰訊軟體中心下載下傳了git、TortoiseGit-2.10.0.0-64bit(原來在官網總下載下傳到一半就沒反應了)
簡單安裝後首先在gitbash裡生成密鑰(實作ssh免密碼登入)
配置使用者名
git config --global user.name "a11"
配置郵箱
git config --global user.email "[email protected]"
生成密鑰對
ssh-keygen -t rsa -C "[email protected]"
複制公鑰到伺服器的authorized_keys
cat ~/.ssh/id_rsa.pub
docker exec -it 398558f43910 /bin/sh (進入git容器)
vi ./.ssh/authorized_keys
git用戶端使用
git clone [email protected]:/home/git/sample.git
git init
git remote add origin [email protected]:/home/git
git push -u origin master
問題:
測試克隆git上的目錄總報沒權限
git clone [email protected]: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.
[email protected]'s password:
Permission denied, please try again.
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
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.
Warning: Permanently added '[172.27.14.222]:30813' (ECDSA) to the list of known hosts.
warning: You appear to have cloned an empty repository.