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
Is there any way to pass the same ssh options to the git clone command?
Edit: There is a restriction that I can't modify ~/.ssh/config
or any other files on that machine.
The recently released git 2.3 supports a new variable "GIT_SSH_COMMAND" which can be used to define a command WITH parameters.
Here is tricky example how to pass the ssh arguments by using GIT_SSH variable:
Note: Above lines are terminal command-lines which you should paste into your terminal. It'll create a file ssh, make it executable and executes it.
If you'd like to pass the private key option, please check How to tell git which private key to use?.
I think that update git to an version >= 2.3 and use
GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" git clone user@host
is the bet option, but if it not possible, @josh-lee gave a good option, but please, update your answer indenting the ssh config file.Another option made to specify different keys is
git config core.sshCommand
with git 2.10 + (Q3 2016).This is an alternative to the environment variable described in Boris's answer)
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)It means the
git clone
can be:If you want to apply that for all repos, as user1300959 adds in the comments, you would use a global configuration.
Add them to your
~/.ssh/config
:The
Host
entry is what you’ll specify on the command line, and theHostName
is the true hostname. They can be the same, or theHost
entry can be an alias. TheUser
entry is used if you do not specifyuser@
on the command line.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.This issue has been fixed by doing follow step's in Window machine:-
Create config file under C:\Users\username.ssh folder.
add the following line to a config file.
then try again.