English 中文(简体)
采用切除办法
原标题:Passing ssh options to git clone
  • 时间:2011-10-14 18:50:41
  •  标签:
  • git
  • ssh

I m试图操作gitlin,而没有核对存放处的钥匙。 我可以这样说:

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no user@host

是否有办法将同样的 options子选项传给威恩指挥?

Edit:我可以限制修改~/ssh/config。 或该机器上的任何其他档案。

最佳回答

Add them to your ~/.ssh/config:

Host host
    HostName host
    User user
    SshOption1 Value1
    SshOption2 Value2

<代码>Host的条目是你在指挥线上具体说明的内容,<代码>HostName是真正的东道名称。 它们可以是相同的,也可以是<代码>Host的条目。 如果你没有具体规定指挥线上的<编码>用户@,则使用<代码>User。

If you must configure this on the command line, set the GIT_SSH environment variable to point to a script with your options in it.

问题回答

最近公布的第2.3类支持新的变量“GIT_SSH_COMMAND”,可用于确定指挥参数。

GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone user@host

$GIT_SSH_COMMAND takes precedence over $GIT_SSH, and is interpreted by the shell, which allows additional arguments to be included.

为具体指明不同的钥匙而采取的另一种选择是git config core.sshCommand with git 2.10 + (Q32016)。

这是在

See commit 3c8ede3 (26 Jun 2016) by Nguyễn Thái Ngọc Duy (pclouds).
(Merged by Junio C Hamano -- gitster -- in commit dc21164, 19 Jul 2016)

A new configuration variable core.sshCommand has been added to specify what value for GIT_SSH_COMMAND to use per repository.

Similar to $GIT_ASKPASS or $GIT_PROXY_COMMAND, we also read from config file first then fall back to $GIT_SSH_COMMAND.

This is useful for selecting different private keys targetting the same host (e.g. github)

core.sshCommand:

If this variable is set, git fetch and git push will use the specified command instead of ssh when they need to connect to a remote system.
The command is in the same form as the GIT_SSH_COMMAND environment variable and is overridden when the environment variable is set.

这意味着<代码>git lin。 可以:

cd /path/to/my/repo
git config core.sshCommand  ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no  
# later on
git clone host:repo.git

如欲申请allrepos,130user0959

git config --global core.sshCommand  ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no 

www.un.org/Depts/DGACM/index_spanish.htm 托存级别配置,不影响系统一级环境

Consolidating the already available answers, I am choosing the below steps. This ensures that the configuration changes do not impact at the machine level, but just for the repository being worked on. This is needed in my case as my script needs to be executed on a shared Bamboo agent.

1. 导言 <代码> GIT_SSH_COMMAND approach.

GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone ssh://url

2. 沉浸在贮存库中。

cd repo-dir

3.Set <代码>分数.sshCommand配置,使今后所有电话都能够像往常一样,在内部使用所提供的优惠选择。

git config core.sshCommand  ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no 

我认为,对版本和大体进行更新;=2.3和使用是必备的选择,但是,如果不可能的话,@josh-lee则提供了一种很好的选择,但请更新你对冲破 s文件的答复。

Host host
    HostName host
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null

更安全的方式是:

git config --global core.sshCommand  ssh -o StrictHostKeyChecking=accept-new 

这比<代码>更安全。 缩略语 <代码>no,可互换。

a. 一次性指挥使用:

git -c core.sshCommand= ssh -o StrictHostKeyChecking=accept-new  clone ...

这个问题通过在温得克机器中采取后续步骤确定:

  • 在C:用户名下编集。

  • 添加以下一行:

    host <HOST>
    hostname <HOSTNAME>
    user <USER_NAME>
    IdentityFile ~/.ssh/id_rsa
    IdentitiesOnly yes
    port <PORT_NUMBER>
    KexAlgorithms +diffie-hellman-group1-sha1
    
  • 然后再次审判。





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签