0

I am trying to automate git cloning of several repositories using Python.Ideally I do not want to have any user intervention when cloning of repositories starts. But I am ending up with prompts listed below for each repository cloning where I have to provide password and confirm ssh authenticity.

python gitClone.py 

Enter Git Local Repository Folder [~/git/work] :

Enter Git Password for user '<user>' :

...Cloning into '~/git/work/xxx' ....

The authenticity of host 'github.com (xx.xxx.xxx.xxx)' can't be established.
ECDSA key fingerprint is 
ECDSA key fingerprint is 
Are you sure you want to continue connecting (yes/no)? y
Password for 'https://<user>@gitlfs.com': 

gitClone.py

    input2 = getpass.getpass(prompt="Enter Git Password for user '" + current_user + "' :")
    if(input2):
        os.environ["GIT_PASSWORD"] = input2

    git_command = ['/usr/bin/git','lfs', 'clone','--config', 'core.askpass=git_askpass_helper.sh', '-b', branch, "git@github.com:myOrg/" + name + '.git']
    print("\n...Cloning into '" + local_dir + "/" + name + "' ....")
    git_query = Popen(git_command, cwd=local_dir, stdout=PIPE, stderr=PIPE, env=dict(os.environ, GIT_SSH_COMMAND="ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyCheck=no"))
    (git_status, error) = git_query.communicate()
    if git_query.poll() == 0:
        print("\nCloning of Git Project myOrg/" + name + " Done!")
    else:
        print("\nError in Cloning Git Project myOrg/" + name + "\n" + error)

git_askpass_helper.sh

#!/bin/sh
echo "$GIT_PASSWORD"

I don't want to have to provide git passsword or confirm ssh authenticity for each repository cloning.

Håken Lid
  • 22,318
  • 9
  • 52
  • 67
  • 4
    Most likely, you are not using ssh as protocol for git cloning, but https instead. Therefore, you get asked about user's password. – Sebi Aug 09 '19 at 08:23
  • 2
    lfs has its own connection to `https://@gitlfs.com` which requires its own password in addition to the one you already give for `git://github.com`. I don't know how one would provide the password for that automated as I don't use lfs. – Dan D. Aug 09 '19 at 08:56
  • Are you using the same server (it looks like `github.com`) for your Git LFS server or are you using a separate one? – bk2204 Aug 09 '19 at 21:04
  • @DanD i think you are right. LFS uses its own authentication which am not finding to automate it. – Veeksha A V Aug 22 '19 at 02:08
  • @bk2204 i think github.com is different from Git LFS server. Git LFS we are using to store large binary files. – Veeksha A V Aug 22 '19 at 02:09

0 Answers0