Passing ssh options to git clone

后端 未结 7 977
礼貌的吻别
礼貌的吻别 2020-11-30 23:16

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/nul         


        
7条回答
  •  生来不讨喜
    2020-11-30 23:54

    Repository level configuration without impacting the system level settings

    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.Clone the repository taking the GIT_SSH_COMMAND approach.

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

    2.Once cloned, navigate into repository directory.

    cd repo-dir
    

    3.Set core.sshCommand configuration so that all future calls can be just run with git commands like usual, but internally consuming the provided git options.

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

提交回复
热议问题