t2 git clone usergit@120.55.17.17:/home/usergit/gitrepo/BRaxVarProject.git
Cloning into 'BRaxVarProject'...
Enter passphrase for key '/Users/nick/.ssh/id_rsa':
usergit@120.55.17.17's password:
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
t2
Git 服務(wù)器搭建
http://www.runoob.com/git/git-server.html
如果服務(wù)器 ssh 訪問需要秘鑰,那么Git 倉庫訪問也需要進(jìn)行相應(yīng)配置晶衷。
1阴孟,將自己的公鑰給到服務(wù)器,添加到服務(wù)器對(duì)應(yīng)的 known_hosts 中锹漱;
- 如果自己沒有公鑰和私鑰哥牍,那么可以自己生成:
ssh-keygen -t rsa -C "ribuluo000@163.com"
.ssh ssh-keygen -t rsa -C "ribuluo000@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/nick/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/nick/.ssh/id_rsa.
Your public key has been saved in /Users/nick/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:pL1AYGrQ2Yg+6JASVSr3DWrsaP3uNsWPZRZlEM/dAs8 ribuluo000@163.com
The key's randomart image is:
+---[RSA 2048]----+
|.+.=+ oo. |
|o.++.. oo= . |
|+o= . . . oo E . |
|=B o + + . . |
|+ = . = S . |
| =. + = |
|.... . B |
|. .o . . |
| ++. |
+----[SHA256]-----+
.ssh
生成過程中需要設(shè)置自己私鑰的密碼喝检,請(qǐng)牢記挠说。
- 服務(wù)器將收到的公鑰放入對(duì)應(yīng)的 known_hosts 中:
cat my_id_ras.pub >> authorized_keys
2,本地配置ssh
在本地 .ssh 目錄下,找到 config 文件蛙奖,如果沒有雁仲,則創(chuàng)建琐脏;
將以下配置代碼放進(jìn)去:
# ------ 官網(wǎng) ------
Host 120.55.17.17
HostName 120.55.17.17
Port 1666
User usergit
IdentityFile ~/.ssh/id_rsa
# ------ 官網(wǎng)結(jié)束 ------
clone 代碼
t2 git clone usergit@120.55.17.17:/home/usergit/gitrepo/BRaxVarProject.git
Cloning into 'BRaxVarProject'...
Enter passphrase for key '/Users/nick/.ssh/id_rsa':
usergit@120.55.17.17's password:
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.
t2