如果需要在 Github 和 Gitlab 环境下,进行代码管理,则需要创建两个 SSH Key. GitHub/GitLab 同时创建 SSH Key
  • Step1 - GitLab SSH Key 创建
cd ~/.ssh
ssh-keygen -t rsa -C "注册的gitlab邮箱"
# 默认名称,直接回车跳过,另外还会提示设置密码,设置密码的话后续登陆会比较麻烦,也直接跳过,创建成功
ls
# 得到两个文件: id_rsa.pub、id_rsa
复制 id_rsa.pub 中的内容,即公钥到 GitLab 账户的SSH Keys里
  • Step2 - GitHub SSH Key 创建
cd ~/.ssh
ssh-keygen -t rsa -C "注册的github邮箱"
# 对生成定的秘钥进行重命名为 id_rsa_github,回车,直接跳过提示设置密码,创建成功
ls
# 新得到两个文件: id_rsa_github.pub、id_rsa_github
复制 id_rsa_github.pub 中的内容,即公钥到 GitHub 账户的SSH Keys里

可能出现问题:

    1. SSH生成id_rsa, id_rsa.pub后,连接服务器却报:Agent admitted failure to sign using the key错误.
执行命令:
ssh-add
Last modification:October 9th, 2018 at 09:31 am