美文网首页
| 为 gitee/github 生成/添加 SSH 公钥

| 为 gitee/github 生成/添加 SSH 公钥

作者: Hemingway_AT | 来源:发表于2020-02-23 10:13 被阅读0次

之前单独为 gitee 添加 SSH 公钥

关联文件 | 码云 gitee

【增】为 github 添加 SSH 公钥

切到 ~/.ssh目录下,欲执行以下官方演示命令,将在 .ssh 目录下默认生成 id_rsa文件。

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

可以预见会与 gitee 那一套有冲突。

  • 因此,对之前 gitee 生成公钥时的关联文件进行重命名
mv id_rsa id_rsa_gitee
mv id_rsa.pub id_rsa_gitee.pub
  • 为 github 生成 SSH 公钥并指定命名
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f "id_rsa_github"
关联文件 | GitHub
  • 将账户添加密钥,内容为id_rsa_github.pub中的字符

拷贝到剪切板的命令如下:

# Mac
$ pbcopy < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
# Windows
$ clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
# Linux
$ sudo apt-get install xclip
# Downloads and installs xclip. If you don't have `apt-get`, you might need to use another installer (like `yum`)

$ xclip -sel clip < ~/.ssh/id_rsa.pub
# Copies the contents of the id_rsa.pub file to your clipboard
  • 进行连接测试,结果发生了意外:Permission denied(出现原因:多个git环境下,使用了自定义的秘钥名称)
ssh -T git@github.com
failure :(

解决方案:新建 config 文件,进行配置,如下

# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_gitee

# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github

再次进行连接测试,就好了!

success :)

参考

相关文章

  • | 为 gitee/github 生成/添加 SSH 公钥

    之前单独为 gitee 添加 SSH 公钥 关联文件 | 码云 gitee 【增】为 github 添加 SSH ...

  • Gitee免密推送和拉取

    生成/添加SSH公钥 访问gitee.com官网,添加SSH公钥 验证是否成功 本地添加帐号

  • Git 配置ssh连接多账户

    生成/添加SSH公钥 SSH Key[https://gitee.com/help/labels/19] SSH ...

  • Git SSH

    进入~/.ssh目录,生成ssh 复制生成的公钥 将刚刚复制的公钥添加到github 测试

  • CentOS+Git+码云,同步代码到服务器端

    git安装 生成SSH公钥 查看公钥 查看你的 public key,并把他添加到码云(Gitee.com) 添加...

  • 一台终端-多个ssh-key配置

    1、生成SSH-Key 2、查看公钥 3、将公钥内容复制粘贴至gitlab/github SSH公钥 4、添加私钥...

  • Git 操作

    添加github ssh本地生成公钥和密钥 然后在 .ssh文件夹里把公钥复制到github上面如果本地已经有公钥...

  • git 关联 gitee

    生成公钥 三次回车即可生成 ssh key 查看公钥 gitee中配置公钥

  • git远程秘钥设置

    1、生成公私钥对 2、绑定公钥 将公钥添加到github网站内获取公钥 将公钥串添加到setting->SSH a...

  • github

    注册github帐号 安装git(不是github) 绑定用户 生成ssh key 为github绑定ssh(公钥...

网友评论

      本文标题:| 为 gitee/github 生成/添加 SSH 公钥

      本文链接:https://www.haomeiwen.com/subject/grorqhtx.html