当前位置:   article > 正文

Git设置SSH Key_git ssh key 配置

git ssh key 配置

一、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”

  1. ssh-keygen -t rsa -C “xinyu.xia@xxx.com”
  2. Generating public/private rsa key pair.
  3. Enter file in which to save the key (/Users/xinyu.xia/.ssh/id_rsa):
  4. Created directory '/Users/xinyu.xia/.ssh'.
  5. Enter passphrase (empty for no passphrase):
  6. Enter same passphrase again:
  7. Your identification has been saved in /Users/xinyu.xia/.ssh/id_rsa
  8. Your public key has been saved in /Users/xinyu.xia/.ssh/id_rsa.pub
  9. The key fingerprint is:
  10. SHA256:QsGezVQx8Ss3u3MtdFE6m6pFdFE3hDNpOq5NFN/CPo4 “xinyu.xia@xxx.com”
  11. The key's randomart image is:
  12. +---[RSA 3072]----+
  13. | .. .=o =+o|
  14. | ... + * .+|
  15. | ..= O =..|
  16. | .o o = *oo |
  17. | . S + B .+.|
  18. | . * =+ .|
  19. | + =o.o |
  20. | . Eooo .|
  21. | ...o . |
  22. +----[SHA256]-----+

(5)配置 ssh 变量
          git config --global ssh.variant ssh

二、gitlab 配置公钥

(1)打开生成公钥的文件夹

  1. xinyu.xia@XinyuXiadebijibendiannao .ssh % cd /Users/xinyu.xia/.ssh
  2. xinyu.xia@XinyuXiadebijibendiannao .ssh % ls
  3. id_rsa id_rsa.pub
  4. xinyu.xia@XinyuXiadebijibendiannao .ssh % cat id_rsa.pub
  5. ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDN625hKNsrAW6JvAQOdAjuMHcd892i23D+ko0MYZeDYCMUCh/vvJjyC0mWQkdIl1ID8f6M7KLgZAC2ZU4GgAOfL+xxxxxxxxxxxxxxxxxUFzB2ntmkvUhLaWTL1f3Gg3DINVpQxxehfQBVKJrJvzXbDbXrmmrLw1ssPfTHp2xnIZYNVXX5XwIdFigogXqBFwQfaYHhDAdEDf+aRtM+njoHncEXt3nazIzQT4k6lSv3AkTNOKGw70qXl2/xxxxxxxxxxxxxenQuswmN3Zr1O3oAQIRsoA42qWhRDOU+gZvh2mBcbTtp/jjQUeeorrnhVNl1hVZr8tQHiuLtV/3lhQm6LqSREcNHecLySDgrsemUFCZq1evy+hveUY5v/liIuHdSXUjUhVpE015kl0SA/t8subu/7rDbpb742zJD0dELZ6bqPH9SNv3RCoap14WyB6vaX+LBOlWPYXIPMlNfZamgtq4i94+2pnRU1G8Afc= “xinyu.xia@xxx.com”

(2)复制公钥文件内容,公钥文件名

 (3)下载代码

  1. xinyu.xia@XinyuXiadebijibendiannao workspace % git clone git@xxx.xxx.net:xxx/xx.git
  2. 正克隆到 'xxx'...
  3. The authenticity of host 'xxx.xxx.net (10.x.x.x)' can't be established.
  4. ED25519 key fingerprint is SHA256:kvb8xBlwU1j/JJCJ5fKkhxKjV7NnMQe4xY5xpoWooww.
  5. This key is not known by any other names
  6. Are you sure you want to continue connecting (yes/no/[fingerprint])? 123456
  7. Please type 'yes', 'no' or the fingerprint: yes
  8. Warning: Permanently added 'xxx.xxx.net' (ED25519) to the list of known hosts.
  9. *******************************************************************************
  10. * *
  11. * *
  12. * This is a private network owned by x.x. xxxxxx *
  13. * *
  14. * Only authorised users are allowed to use the services provided. *
  15. * *
  16. * *
  17. *******************************************************************************
  18. xxx.xxx.net
  19. 警告:您似乎克隆了一个空仓库。

三、利用token连接Git仓库 

git clone https://github-username:github-password@github.com/username/project.git

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/运维做开发/article/detail/950949
推荐阅读
相关标签
  

闽ICP备14008679号