1. Gitlab 服务器地址 http://192.168.1.104
  2. 开发电脑系统 Ubuntu 18.04
  3. Gitlab 已有账号 mao_siyu
  4. Gitlab 已有邮箱 maosiyu@boqihuixin.com

生成 SSH Key

mao-siyu@pc:/mnt/1TB/devProject/bqhx-member$ ssh-keygen -t rsa -C "maosiyu@boqihuixin.com" -b 4096
Generating public/private rsa key pair.
# 直接回车
Enter file in which to save the key (/home/mao-siyu/.ssh/id_rsa): 
/home/mao-siyu/.ssh/id_rsa already exists.
Overwrite (y/n)? y
# 直接回车
Enter passphrase (empty for no passphrase): 
# 直接回车
Enter same passphrase again: 
Your identification has been saved in /home/mao-siyu/.ssh/id_rsa.
Your public key has been saved in /home/mao-siyu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:1jX4dEcxg7wu+m1ucf87sN2AMi0GATPdQDvgL4C1DvM maosiyu@boqihuixin.com
The key's randomart image is:
+---[RSA 4096]----+
|    . =+oo  . .+o|
|   o o +o... o .o|
|  + o . o.. + o .|
|   = . ..o + + . |
|    E . S...o.   |
|       o  =.o+.. |
|         ..+. *.o|
|         .  .+ oo|
|          ..+o .=|
+----[SHA256]-----+

查看生成的公钥, 并将公钥粘贴到 Gitlab的SSH配置中;

mao-siyu@pc:/mnt/1TB/devProject/bqhx-member$ cat /home/mao-siyu/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDdhNPw7taiFieCmiaHA045+Fe2xlRaD7oe3jjaZOQN6bP8yXRV4LdvwgBbfzZqWBxn9ArTVCNpkz21Az8iPFGGtEfxltMMSHzIK8cGmBFzisfEAE5U5+Z1QKS/onJZAhDfCUmGAPKzOumvOWldtZlqYcFFwNXMX5oSUzcOj2IGMdXpw7GabcONfIGXZh7CqCgtxZg7czOnb+nU+HMVdBrMs4hrlxIWoSC3IGsxC8L82bRc1m4LTqCHRvOTTOzDlcnh8ApEfCGaaIbbpdMeDVSvjtXxofhMAPqzvsRXQBgYOaDU5+PYgEJpsvk0BC/L1UpPcu4+48W5Si7q8npDaaVGUognkozQnApCZFBm/heqt74Gc6IZwjx8bpu+qtz1pq1QQxbxbW/vuUTqWf0rPei8ElNfNxBFEjJEyrU0TL5KeM5Z8WIASja2il1g0T8l86eqsf1iq/RVZ7nIjjGo6Uqa3BFFmPTQlcVvUj+wML1+niGaGjfGPYSAhlEii5KxZ3Ok9daAtc/pxfmguf01IbzzlIq8reZ4hCm3L3Jtj4y1ow1Fi408k92jvyGtmB5XgxEo2q/ery9tBuL0sipiN/sBm9m6kY3ucrenDV0QPJTL9w3XIwU2CBU0jlvR6UlVh3R7a9LvWJ4WgBnxRTrVyw8h7djvvRDcjGEp6wz6dps5jQ== maosiyu@boqihuixin.com
mao-siyu@pc:/mnt/1TB/devProject/bqhx-member$

配置全局git账号

mao-siyu@pc:/mnt/1TB/devProject/bqhx-member$ git config --global user.name 'mao_siyu'
mao-siyu@pc:/mnt/1TB/devProject/bqhx-member$ git config --global user.email 'maosiyu@boqihuixin.com'
mao-siyu@pc:/mnt/1TB/devProject/bqhx-member$ git config --global --list
user.name='mao_siyu'
user.email='maosiyu@boqihuixin.com'

测试是否配置成功

#  ssh -T git@你的服务器IP地址
mao-siyu@pc:/mnt/1TB/devProject/bqhx-member$ ssh -T git@192.168.1.104
Welcome to GitLab, 毛巳煜!
mao-siyu@pc:/mnt/1TB/devProject/bqhx-member$

使用SSH方式下载项目

mao-siyu@pc:/mnt/1TB/devProject/bqhx-member$ git clone git@192.168.1.104:group_member_web/bqhx-member-web.git
正克隆到 'bqhx-member-web'...
remote: Counting objects: 67, done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 67 (delta 19), reused 0 (delta 0)
接收对象中: 100% (67/67), 282.68 KiB | 21.74 MiB/s, 完成.
处理 delta 中: 100% (19/19), 完成.
mao-siyu@pc:/mnt/1TB/devProject/bqhx-member$

发表评论

电子邮件地址不会被公开。 必填项已用*标注