使用密钥连接gitlab
-
首先安装好git,安装地址如下
https://git-scm.com/download/win
-
在桌面,鼠标右键单击,选择Git Bash Here
-
生成密钥,如下
$ ssh-keygen.exe -t ED25519 Generating public/private ED25519 key pair. Enter file in which to save the key (/c/Users/haifeng.gao/.ssh/id_ed25519): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/haifeng.gao/.ssh/id_ed25519 Your public key has been saved in /c/Users/haifeng.gao/.ssh/id_ed25519.pub The key fingerprint is: SHA256:bR4e/mpXG8qPnFS+mEOye9MuDJi7Jm7Q4C/FnBr+rHs haifeng.gao@XMITDN0504240 The key's randomart image is: +--[ED25519 256]--+ | | | | | | | . . | | . = .So= . | | + * o=oo.oo | | . * .+B.+.o | | +.E o o+X=o. | | oO+o.oo=B*+ | +----[SHA256]-----+
-
将公钥导入到gitlab中的SSH Keys中,如下
-
切换至 Git Bash
$ git clone git@gitlab.ximalaya.com:xmops/salt-nginx-uat.git Cloning into 'salt-nginx-uat'... The authenticity of host 'gitlab.ximalaya.com (192.168.41.25)' can't be established. ED25519 key fingerprint is SHA256:yupomENs/fYD2rX/y01+UHs22f+4jxGNPnNpnE3j9wc. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'gitlab.ximalaya.com' (ED25519) to the list of known hosts. remote: Enumerating objects: 119, done. remote: Counting objects: 100% (119/119), done. remote: Compressing objects: 100% (57/57), done. remote: Total 26607 (delta 58), reused 89 (delta 42) Receiving objects: 100% (26607/26607), 3.54 MiB | 8.58 MiB/s, done. Resolving deltas: 100% (15817/15817), done.
遇到的错误
-
错误1,在使用rsa类型遇到的,换成
ED25519 就可以了
$ git clone git@gitlab.ximalaya.com:xmops/salt-nginx-uat.git Cloning into 'salt-nginx-uat'... The authenticity of host 'gitlab.ximalaya.com (192.168.41.25)' can't be established. ED25519 key fingerprint is SHA256:yupomENs/fYD2rX/y01+UHs22f+4jxGNPnNpnE3j9wc. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'gitlab.ximalaya.com' (ED25519) to the list of known hosts. git@gitlab.ximalaya.com's password:
原创文章,作者:奋斗,如若转载,请注明出处:https://blog.ytso.com/271632.html