生成秘钥文件
- 示例如下,这里给文件取名github, 密码任意输入
ssh-keygen -t rsa -C 'nick@xx.com' -f ~/.ssh/github
cat github.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/0cOZeaajHo1gMFU7APUn1QWPGrdtIFAdfFuYCw0xdEIgd8fKaRNanVTm/mrVXgSRy11Est1mtS6PQhu1Yiq6VHdtWMKpc8TlkxC9OpISaf4p+Hkkzv4G+jQK2NCVgPnkJ383GCDobbKoq1o/mSNKxkMLGBFjgEohe6vHwXEX9QkHmIlLPWG6aTIV+FkQcB+avIh6jObPrsUfLU9TubdZdwVrtsgOeqcVrQr+LyNGZU2ytF4+lRz2IOM5e3cam7jMeBHzgQGmojz4e9tc/HFqiUXg3pcihSthJc0DzTgNTJij49K6U0OOURhUChxnc1C+8Iadts9q5EfaU2AJlwrhj qiujiahongde@163.com
- 专用密钥添加到ssh-agent的高速缓存中(下面github是第一步取的文件名)
ssh-add ~/.ssh/github
Enter passphrase for /Users/fangle/.ssh/github:
Identity added: /Users/fangle/.ssh/github (/Users/fangle/.ssh/github)
导入ssh key到github上
image.png测试登陆
ssh -T git@github.com
The authenticity of host 'github.com (192.30.253.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.253.113' (RSA) to the list of known hosts.
Hi qiujiahong! You've successfully authenticated, but GitHub does not provide shell access.
补充说明,gitlab上面的设置方法类似,读者可以通过以上方法设置多个git链接多个服务器;
网友评论