生成公钥
$ ssh-keygen -t rsa -C "youremail@qq.com" Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/HUI/.ssh/id_rsa): /c/Users/HUI/.ssh/id_rsa_coding //需要添加GitHub或gitee这儿请不要使用默认文件名 Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/HUI/.ssh/id_rsa_coding. Your public key has been saved in /c/Users/HUI/.ssh/id_rsa_coding.pub. The key fingerprint is: SHA256:mADKJltej9ievZSJXiXOPEkrqBHjeXdWOgi8MKTOznM youremail@qq.com The key's randomart image is: +---[RSA 3072]----+ | . | |.. . | |oo. o | |o= + + o | |* + o * S | |o=.= O B . | |+.+.B # o | |.* E.* B | |ooo.o + . | +----[SHA256]-----+ $ ssh-add id_rsa_coding Identity added: id_rsa_coding (youremail@qq.com) $ ssh-add -l //查看 3072 SHA256:mADKJltej9ievZSJXiXOPEkrqBHjeXdWOgi8MKTOznM youremail@qq.com (RSA)
在C:UsersAdmin.ssh目录中创建config配置文件
#将内容复制到config文件中
Host conding.com HostName e.coding.net IdentityFile ~/.ssh/id_rsa_coding
SSH key密钥加入ssh agent中
$ ssh-add -D //agent中的密钥先删除 $ ssh-add id_rsa_coding
配置Coding公钥
进入公钥目录打开C:UsersAdmin.sshid_rsa_coding.pub 复制内容
粘贴到Coding添加公钥处
测试是否连接成功
$ ssh -T git@conding.com Coding 提示: Hello hlikex, You've connected to Coding.net via SSH. This is a personal key. hlikex,你好,你已经通过 SSH 协议认证 Coding.net 服务,这是一个个人公钥. 公钥指纹:d6:ca:ec:4c:99:45:7c:9a:40:33:cf:5c:f2:d9:fd:72