$ ssh-keygen -t rsa -C "your_email@youremail.com" Generating public/private rsa key pair. Enter file in which to save the key (/c/Users/用户名/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /c/Users/用户名/.ssh/id_rsa. Your public key has been saved in /c/Users/用户名/.ssh/id_rsa.pub. The key fingerprint is: SHA256:aTdcC........................mQAU your_email@youremail.com The key's randomart image is: +---[RSA 2048]----+ | .Eo. +o=.....o | | . o *o+o..+oo| | . . B +. *.=.o| | . = =o + * +.| | + +S.= + ...| | * ..oo + .| | . .o | | Eo . . . | | o . .. | +----[SHA256]-----+
# second user(second@mail.com) # 建一个github别名,新建的帐号使用这个别名做克隆和更新 Host github2 HostName github.com User git IdentityFile C:/Users/Administrator/.ssh/id_rsa_work
执行测试
1
ssh -T git@Host别名
上述命令会自动生成known_hosts文件把私钥配置进文件中
内容如下:
1 2 3 4 5 6
$ ssh -T git@percy The authenticity of host 'github.com (13.250.177.223)' can't be established. RSA key fingerprint is SHA256:nThbg.............................Kw6E5SY8. Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'github.com,13.250.177.223' (RSA) to the list of known hosts. Hi percy! You've successfully authenticated, but GitHub does not provide shell access.