V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
git
Pro Git
Atlassian Git Tutorial
Pro Git 简体中文翻译
GitX
cevincheung
V2EX  ›  git

我又来问 GIT 的多部署公钥问题了 -_-

  •  
  •   cevincheung · 2016-10-16 12:29:00 +08:00 · 2571 次点击
    这是一个创建于 2742 天前的主题,其中的信息可能已经有所发展或是发生改变。

    旧帖:/t/313047

    不同的 host 的主机在 config 中配置 hostname 就可以了。现在我这么配置的

    # /home/www-data/.ssh/config
    
    Host git.coding.net
    HostName git.coding.net
    User git
    IdentityFile ~/.ssh/weixin
    
    Host github.com
    HostName github.com
    User git
    IdentityFile ~/.ssh/project2
    

    但是现在我在 github 上托管了两个项目,也就是说同一个 host 有两个部署密钥。这种情况怎么设置 config 文件?

    放狗后说是要把 host 改成*.git的名字。。测试无效。。

    CentOS 6.8 / git 1.7.1

    11 条回复    2016-10-17 00:49:31 +08:00
    ryd994
        1
    ryd994  
       2016-10-16 13:16:52 +08:00
    除非你有两个帐号,否则任何一个都可以用
    而有两个帐号的情况下,没有办法,因为 ssh 只负责连接这段,后面路径是由 git 处理的
    ryd994
        2
    ryd994  
       2016-10-16 13:17:47 +08:00
    说到底,不是很懂为什么你要多个公钥
    只要私钥不泄露,所有网站都可以用同一个
    yangg
        3
    yangg  
       2016-10-16 13:19:10 +08:00
    以一个帐号为主帐号,另一个帐号的项目 2 添加主帐号的 token ,允许其访问就行了,
    wxg4net
        4
    wxg4net  
       2016-10-16 13:19:53 +08:00   ❤️ 2
    这不很简单么
    Host project2 ##这个名称任意定义
    HostName github.com
    User git
    IdentityFile ~/.ssh/project2
    Host projec1 ##这个名称任意定义
    HostName github.com
    User git
    IdentityFile ~/.ssh/project1
    地址这样 git://projec2/yourproject2.git git://projec1/yourproject1.git
    cevincheung
        5
    cevincheung  
    OP
       2016-10-16 13:27:13 +08:00
    @wxg4net 所以需要设置系统的 hosts 吗?
    cevincheung
        6
    cevincheung  
    OP
       2016-10-16 13:37:40 +08:00
    @wxg4net 已搞定。谢。
    wayslog
        7
    wayslog  
       2016-10-16 13:45:48 +08:00 via Android
    恭喜解决了……但是没搞懂为啥要多个公钥……
    skydiver
        8
    skydiver  
       2016-10-16 13:50:25 +08:00 via Android
    host 可以自己起,没必要用域名
    wwwjfy
        9
    wwwjfy  
       2016-10-16 15:03:14 +08:00
    楼上没看明白的,部署密钥是一个项目一个,不是属于用户的, deployment key
    cevincheung
        10
    cevincheung  
    OP
       2016-10-16 17:08:44 +08:00
    @wayslog 同一个平台的多个项目组分开的不同的部署公钥分发在不同的 server 上。
    ychongsaytc
        11
    ychongsaytc  
       2016-10-17 00:49:31 +08:00 via iPhone
    host 和 hostname 不必一致
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2869 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 11:19 · PVG 19:19 · LAX 04:19 · JFK 07:19
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.