将 ssh 选项传递给 git clone [英] Passing ssh options to git clone

查看:25
本文介绍了将 ssh 选项传递给 git clone的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行 git clone 而无需 ssh 检查存储库主机的密钥.我可以像这样从 ssh 做到这一点:

I'm trying to run git clone without ssh checking the repository host's key. I can do it from ssh like that:

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

有没有办法将相同的 ssh 选项传递给 git clone 命令?

Is there any way to pass the same ssh options to the git clone command?

有一个限制,我不能修改 ~/.ssh/config 或该机器上的任何其他文件.

There is a restriction that I can't modify ~/.ssh/config or any other files on that machine.

推荐答案

将它们添加到您的 ~/.ssh/config:

Host host
    HostName host
    User user
    SshOption1 Value1
    SshOption2 Value2

Host 条目是您将在命令行中指定的内容,HostName 是真正的主机名.它们可以相同,或者 Host 条目可以是别名.如果未在命令行中指定 user@,则使用 User 条目.

The Host entry is what you’ll specify on the command line, and the HostName is the true hostname. They can be the same, or the Host entry can be an alias. The User entry is used if you do not specify user@ on the command line.

如果您必须在命令行上进行配置,请将 GIT_SSH 环境变量设置为指向包含您的选项的脚本.

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.

这篇关于将 ssh 选项传递给 git clone的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆