I'm trying to clone a project from git using Python's Gitpython library, but instead of password i want to use ssh keys for authentication. I've created a pair of private and public keys and put the public in git and the private in the project directory. In my code i'm using the following commands:
My import:
from git import Repo
The clone command:
ssh_cmd = 'ssh -i private_key.ppk'
Repo.clone_from(GIT_USERS_URL, local_git_dir, env={'GIT_SSH_COMMAND': ssh_cmd})
'private_key.ppk' is the name of the private key file.
When running the script i get the following error:
Permission denied, please try again.
Permission denied, please try again.
Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I know this question has been asked a lot but none of the solutions worked and i don't see why ?
I also run the following commands before i reach the clone statement:
git_process = git.Git(**path to folder to be pushed later on to git**)
git_process.update_environment(SSH_KEY=SSH_PRIVATE_KEY)
Where SSH_PRIVATE_KEY is the path to the private key.
What am i missing ?
Thanks !