git ssh登陆
【摘要】 生成秘钥文件
示例如下,这里给文件取名github, 密码任意输入
ssh-keygen -t rsa -C 'nick@xx.com' -f ~/.ssh/github
cat github.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC/0cOZeaajHo1gMFU7APUn1QWPGrdtIFAdfFuYCw0xdEIgd8...
生成秘钥文件
- 示例如下,这里给文件取名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上
测试登陆
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链接多个服务器;
文章来源: www.jianshu.com,作者:Nick_4438,版权归原作者所有,如需转载,请联系作者。
原文链接:www.jianshu.com/p/d5a6d15a1f84
【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)