【问题标题】:Satis - specify SSH key to git serverSatis - 指定 SSH 密钥到 git 服务器
【发布时间】:2015-08-31 01:49:51
【问题描述】:

我有一个这样指定的 satis.json 文件:

{
    "name": "My organizations Satis Server",
    "homepage": "http://satis.mydomain.org",
    "repositories": [
        {
            "type": "vcs",
            "url": "git@git.mydomain.org:/home/git/packages/MyPackage",
            "options": {
                "ssh2": {
                    "username": "git",
                    "pubkey_file": "/config/public-key.pub",
                    "privkey_file": "/config/private-key"
                }
            }
        },
        ...

然后我尝试通过运行命令来满足更新:

/usr/bin/php /path/to/satis/satis -n build /path/to/satis.json /path/to/location

这将完全忽略我已指定公钥文件和私钥文件的事实,并继续要求我输入密码。如果我每次都手动输入密码。如果我将 ssh 键移动到 .ssh/id_rsa.ssh/id_rsa.pub 并删除选项参数,那么它也可以工作。

问题

如何正确指定每个 repo 的密钥文件,以便我可以为不同的存储库使用不同的密钥,而不是依赖 .ssh/id_rsa 中的一个密钥

【问题讨论】:

  • 投反对票的人能解释一下原因吗?

标签: ssh-keys satis


【解决方案1】:

在构建静态存储库时,使用 -n 开关来使用 $HOME/.ssh 文件夹中当前用户可用的公共 ssh 密钥。

【讨论】:

    【解决方案2】:

    作为一种解决方法,我设法为 satis.json 文件中的所有主机设置了 $HOME/.ssh/config 文件 (Nixcraft reference),如下所示:

    Host git.mydomain.org
         HostName git.mydomain.org
         User git
         Port 22
         IdentityFile /path/to/private-key
    
    Host git.mySecondDomain.org
         HostName git.mySecondDomain.org
         User git
         Port 22
         IdentityFile /path/to/private-key2
    

    我的 satis.json 文件现在看起来像:

    {
        "name": "My organizations Satis Server",
        "homepage": "http://satis.mydomain.org",
        "repositories": [
            {
                "type": "vcs",
                "url": "git@git.mydomain.org:/home/git/packages/MyPackage"
            },
            {
                "type": "vcs",
                "url": "git@git.mySecondDomain.org:/home/git/packages/SecondPackage"
            },
            ...
    

    这是相当不雅的,我希望仍有一种方法可以指定要在 satis.json 文件中使用的密钥的路径。

    【讨论】:

      猜你喜欢
      • 2014-12-06
      • 2016-08-20
      • 2014-04-04
      • 1970-01-01
      • 2017-01-30
      • 1970-01-01
      • 1970-01-01
      • 2019-12-07
      • 2018-04-16
      相关资源
      最近更新 更多