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 服务器搭建
http://www.runoob.com/git/git-server.html
如果服务器 ssh 访问需要秘钥,那么Git 仓库访问也需要进行相应配置。
1,将自己的公钥给到服务器,添加到服务器对应的 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
生成过程中需要设置自己私钥的密码,请牢记。
- 服务器将收到的公钥放入对应的 known_hosts 中:
cat my_id_ras.pub >> authorized_keys
2,本地配置ssh
在本地 .ssh 目录下,找到 config 文件,如果没有,则创建;
将以下配置代码放进去:
# ------ 官网 ------
Host 120.55.17.17
HostName 120.55.17.17
Port 1666
User usergit
IdentityFile ~/.ssh/id_rsa
# ------ 官网结束 ------
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
网友评论