【问题标题】:How to change location of ssh keys for openshift如何更改 openshift 的 ssh 密钥的位置
【发布时间】:2015-12-31 00:28:17
【问题描述】:

我正在设置 rhc 客户端工具以连接到 OpenShift。在“rhc setup”期间,假设在以下位置生成 ssh 密钥:

~/.ssh/

但是,这个 .ssh 文件夹被用于另一个连接,我不希望修改这个文件夹。

是否可以在 rhc 设置期间以某种方式为 ssh 密钥生成指定不同的位置?

因为在 rhc 设置期间,我没有被问到在哪里生成密钥,我还查看了 ~/.openshift/express.conf,我只看到了 ssl 的配置;不是 ssh。

谢谢。

【问题讨论】:

    标签: ssh openshift ssh-keys openshift-client-tools


    【解决方案1】:

    不确定它如何在 Windows 上运行。您是否尝试在运行 rhc 时设置 HOME 环境变量?或者任何 HOME* windows 上的变量来指定用户的主目录(HOMEPATH,HOMEDRIVE ...)。

    我只能假设谁反对这是一个白痴。刚刚在 linux 上尝试过,它正在工作。我无法在 Windows 上进行测试,但它很可能也可以在那里工作。无论如何,对于那些觉得它有用的人:

    $ HOME=/home/crackit/newhome rhc setup
    OpenShift Client Tools (RHC) Setup Wizard
    
    This wizard will help you upload your SSH keys, set your application namespace,
    and check that other programs like Git are properly installed.
    
    If you have your own OpenShift server, you can specify it now. Just hit enter to
    use the server for OpenShift Online: openshift.redhat.com.
    Enter the server hostname: |openshift.redhat.com| 
    
    You can add more servers later using 'rhc server'.
    
    Login to openshift.redhat.com: xxxxx@yyyyyy.zzz
    Password: *************
    
    OpenShift can create and store a token on disk which allows to you to access the
    server without using your password. The key is stored in your home directory and
    should be kept secret.  You can delete the key at any time by running 'rhc
    logout'.
    Generate a token now? (yes|no) yes
    Generating an authorization token for this client ... lasts about 1 month
    
    Saving configuration to /home/crackit/newhome/.openshift/express.conf ... done
    
    No SSH keys were found. We will generate a pair of keys for you.
    
        Created: /home/crackit/newhome/.ssh/id_rsa.pub
    
    Your public SSH key must be uploaded to the OpenShift server to access code.
    Upload now? (yes|no)
    yes
    
      default (type: ssh-rsa)
      -----------------------
        Fingerprint: ba:49:1e:2a:22:1d:e4:69:3b:ee:62:09:dc:2d:4c:f1
    
      dpospisi (type: ssh-rsa)
      ------------------------
        Fingerprint: 83:89:a7:c4:bd:31:31:8c:26:a4:82:a5:8e:6e:c0:65
    
    You can enter a name for your key, or leave it blank to use the default name.
    Using the same name as an existing key will overwrite the old key.
    
    Provide a name for this key: |asdfghhjjkk| gah
    
    Uploading key 'gah' ... done
    
    Checking for git ... found git version 2.1.0
    
    Checking common problems .. done
    
    Checking for a domain ... asdfghh
    
    Checking for applications ... found 2
    
      jenkins http://aaaa-bbbbbb.rhcloud.com/
      tmp     http://tmp-bbbbbb.rhcloud.com/
    
      You are using 2 of 3 total gears
      The following gear sizes are available to you: small, medium
    
    Your client tools are now configured.
    

    【讨论】:

    • @King-Wizard,如果您在其他位置已经有一个密钥(由 HOME 环境变量指定),那么它不会创建一个新的对。我看到你的问题是不同的。我查看了源代码,我看到在lib/rhc/config.rb 中硬编码为~/.ssh/id_rsa 的ssh 密钥。没有命令行选项会影响rhc setup 的 ssh 设置。因此,您可以在 rhc 设置中选择 No,然后使用 rhc sshkey add 命令添加密钥,或者您可以解释您尝试做什么以及为什么要这样做以获得更好的答案。
    • 第 1/2 部分:@akostadinov 让我们想象一下,如果我不想设置 $HOME 环境变量,而是想使用位于某个自定义路径的 ssh 密钥。还要考虑到我的~/.ssh/config 文件配置良好且配置良好,并指向我的 ssh 密钥所在的自定义路径。在将ssh_key_file='~/.ssh/OpenShift-SSH-Keys/my_id_rsa' 添加到~/.openshift/custom-express.conf 并运行rhc setup --config ~/.openshift/custom-express.conf -l <login> 之后,我可以注意到rhc setup 考虑了该文件
    • 第 2/2 部分:@akostadinov 但rhc cli 似乎没有考虑ssh_key_file='~/.ssh/OpenShift-SSH-Keys/my_id_rsa' 指令。根据您的说法,为什么不考虑它,您将如何解决该问题?指令的语法是否错误或已弃用?
    • @King-Wizard,至于why,我不能说。正如我所说,ssh 密钥部分几乎是硬编码的。编写工具时很可能没有考虑该用例。如果你愿意,你可以提交一个错误。但在我个人看来,rhc setup 旨在涵盖最常见的用例。如果你想要一些异国情调的东西,你需要一些其他的命令。我在你的其他问题中给你写了这些命令。
    • 对于那些想知道的人 - 这是另一个问题:stackoverflow.com/a/34559668/520567
    【解决方案2】:

    如果您的 .ssh 文件夹中已有 ssh 密钥,rhc setup 命令可能会询问您是否要上传现有密钥,而不是创建新密钥。如果您登录到 openshift web 控制台,您可以查看它是否为您上传了密钥。

    【讨论】:

    • 不回答具体问题。
    猜你喜欢
    • 2012-04-28
    • 2023-01-16
    • 2018-09-08
    • 2016-08-15
    • 2010-09-10
    • 1970-01-01
    • 2020-04-01
    • 2021-01-03
    • 2019-09-04
    相关资源
    最近更新 更多