一、git 配置
(1)打开 git 命令窗口
(2)配置用户名(填自己的姓名)
git config --global user.name “xinyu.xia”
(3)配置用户邮箱(填自己的邮箱)
git config --global user.email “xinyu.xia@xxx.com”
(4)生成公钥、秘钥(填自己的邮箱,执行后需要按几次 enter 直到结束)
ssh-keygen -t rsa -C “xinyu.xia@xxx.com”
ssh-keygen -t rsa -C “xinyu.xia@xxx.com” Generating public/private rsa key pair.
Enter file in which to save the key (/Users/xinyu.xia/.ssh/id_rsa):
Created directory '/Users/xinyu.xia/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/xinyu.xia/.ssh/id_rsa
Your public key has been saved in /Users/xinyu.xia/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:QsGezVQx8Ss3u3MtdFE6m6pFdFE3hDNpOq5NFN/CPo4 “xinyu.xia@xxx.com”
The key's randomart image is:
+---[RSA 3072]----+
| .. .=o =+o|
| ... + * .+|
| ..= O =..|
| .o o = *oo |
| . S + B .+.|
| . * =+ .|
| + =o.o |
| . Eooo .|
| ...o . |
+----[SHA256]-----+
(5)配置 ssh 变量
git config --global ssh.variant ssh
二、gitlab 配置公钥
(1)打开生成公钥的文件夹
xinyu.xia@XinyuXiadebijibendiannao .ssh % cd /Users/xinyu.xia/.sshxinyu.xia@XinyuXiadebijibendiannao .ssh % ls
id_rsa id_rsa.pubxinyu.xia@XinyuXiadebijibendiannao .ssh % cat id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDN625hKNsrAW6JvAQOdAjuMHcd892i23D+ko0MYZeDYCMUCh/vvJjyC0mWQkdIl1ID8f6M7KLgZAC2ZU4GgAOfL+xxxxxxxxxxxxxxxxxUFzB2ntmkvUhLaWTL1f3Gg3DINVpQxxehfQBVKJrJvzXbDbXrmmrLw1ssPfTHp2xnIZYNVXX5XwIdFigogXqBFwQfaYHhDAdEDf+aRtM+njoHncEXt3nazIzQT4k6lSv3AkTNOKGw70qXl2/xxxxxxxxxxxxxenQuswmN3Zr1O3oAQIRsoA42qWhRDOU+gZvh2mBcbTtp/jjQUeeorrnhVNl1hVZr8tQHiuLtV/3lhQm6LqSREcNHecLySDgrsemUFCZq1evy+hveUY5v/liIuHdSXUjUhVpE015kl0SA/t8subu/7rDbpb742zJD0dELZ6bqPH9SNv3RCoap14WyB6vaX+LBOlWPYXIPMlNfZamgtq4i94+2pnRU1G8Afc= “xinyu.xia@xxx.com”
(2)复制公钥文件内容,公钥文件名
(3)下载代码
xinyu.xia@XinyuXiadebijibendiannao workspace % git clone git@xxx.xxx.net:xxx/xx.git
正克隆到 'xxx'...
The authenticity of host 'xxx.xxx.net (10.x.x.x)' can't be established.
ED25519 key fingerprint is SHA256:kvb8xBlwU1j/JJCJ5fKkhxKjV7NnMQe4xY5xpoWooww.
This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? 123456
Please type 'yes', 'no' or the fingerprint: yes
Warning: Permanently added 'xxx.xxx.net' (ED25519) to the list of known hosts.*******************************************************************************
* *
* *
* This is a private network owned by x.x. xxxxxx *
* *
* Only authorised users are allowed to use the services provided. *
* *
* *
*******************************************************************************
xxx.xxx.net警告:您似乎克隆了一个空仓库。