• 一台电脑同时添加git和bitbucket两个网站的ssh key


    添加第一个ssh key 就不多说了,不懂的可以自己查资料

    ssh-keygen -t rsa -C 'email_1@email.com'
    

    然后一路enter就好了

    假设已经添加好了git的ssh key 。现在要添加bitbucket的ssh key

    首先

    ssh-keygen -t rsa -C 'email_2@email.com'  //同一个邮箱也可以
    

    然后指定公钥的时候,自己命名:例如 /c/Users/Administrator/.ssh/id_rsa_2 (默认名字是id_rsa,假设已经被git用了)

    然后一路enter就好了

    打开~/.ssh/config文件(没有则创建),添加一个Host。内容如下

    如果是bitbucket

    #建一个bitbucket别名,新建的帐号使用这个别名做克隆和更新
    Host my_bitbucket
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/id_rsa_2.pub
    

    如果是git

    #建一个github别名,新建的帐号使用这个别名做克隆和更新
    Host my_github
    HostName github.com
    User git
    IdentityFile ~/.ssh/id_rsa_2.pub
    

    然后,使用ssh-add添加你的新ssh

    ssh-add /c/Users/Administrator/.ssh/id_rsa_2
    
    

    如果出现提示:Could not open a connection to your authentication agent.
    则先:

    ssh-agent bash
    ssh-add /c/Users/Administrator/.ssh/id_rsa_2
    

    下一步,将ssh key id_rsa_2 添加到git/bitbucket上。然后执行git clone

    // 假如原始命令是
    git clone git@bitbucket.org:somthing/mail.git
    //那么你应该用如下命令
    git clone my_github:somthing/mail.git
    
    遗留问题

    bitbucket网站,第一天正常,过几天执行pull命令的时候,出现“Permission denied (publickey)”,最终解决方案是修改config文件

    Host bitbucket
    HostName bitbucket.org
    User git
    IdentityFile ~/.ssh/id_rsa_bit
    
    
    Host gitee
    HostName gitee.com
    User git
    IdentityFile ~/.ssh/id_rsa_gitee.pub
    

    疑问点:bitbucket上IdentityFile 用的是私钥,而不是公钥,暂时没搞明白。但是我在码云平台上我用的却还是公钥

    参考网址:https://blog.csdn.net/u010387196/article/details/41266255

  • 相关阅读:
    Java基础6
    多行文本框回车换行设置
    CentOS7系统配置国内yum源和epel源
    System Integrity Protection (SIP) iOS10.15安装软件提示文件损坏问题解决方法
    转载:Spring Boot 不使用默认的 parent,改用自己的项目的 paren
    微软Speech语音合成技术
    反编译工具
    线性链表的代码实现
    不一样的鸡汤,你有房吗?你有车吗?你有房车吗?
    递归,迭代和回调
  • 原文地址:https://www.cnblogs.com/qq917937712/p/11326142.html
Copyright © 2020-2023  润新知