Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork941
Closed
Description
hi~ I can't use my id_rsa key to clone my repo.
this is my directory structure:
├── code
├── git_test.py
├── id_rsa
├── id_rsa.pub
└── ssh_executable.sh
git_test.py
importosimportgitfromgitimportRepofromgitimportGitgit_url="git@xxx/xxx.git"git_branch="master"out_dir="./code"# Onegit_ssh_identity_file=os.path.expanduser('./id_rsa')git_ssh_cmd='ssh -i %s'%git_ssh_identity_filewithGit().custom_environment(GIT_SSH_COMMAND=git_ssh_cmd):repo=Repo.clone_from(git_url,out_dir,branch="master")print("Success")# Twossh_executable=os.path.join("./",'ssh_executable.sh')withGit().custom_environment(GIT_SSH=ssh_executable):repo=Repo.clone_from(git_url,out_dir,branch="master")print("Success")
ssh_executable.sh
#!/bin/shID_RSA="./id_rsa"exec /usr/bin/ssh -o StrictHostKeyChecking=no -i$ID_RSA"$@"
I tried both methods and could not succeed clone repo....
if I move theid_res
id_res.pub
to~/.ssh
. it will success. hoping to get your help~
Traceback (most recent call last): File "git_test.py", line 15, in <module> repo = Repo.clone_from(git_url, out_dir, branch="master") File "/Users/frank/miniconda3/lib/python3.7/site-packages/git/repo/base.py", line 988, in clone_from return cls._clone(git, url, to_path, GitCmdObjectDB, progress, **kwargs) File "/Users/frank/miniconda3/lib/python3.7/site-packages/git/repo/base.py", line 939, in _clone finalize_process(proc, stderr=stderr) File "/Users/frank/miniconda3/lib/python3.7/site-packages/git/util.py", line 333, in finalize_process proc.wait(**kwargs) File "/Users/frank/miniconda3/lib/python3.7/site-packages/git/cmd.py", line 415, in wait raise GitCommandError(self.args, status, errstr)git.exc.GitCommandError: Cmd('git') failed due to: exit code(128) cmdline: git clone --branch=master -v git@my.address.git ./code stderr: 'Cloning into './code'...git@gitlab.alipay-inc.com: Permission denied (publickey).fatal: Could not read from remote repository.Please make sure you have the correct access rightsand the repository exists.
Metadata
Metadata
Assignees
Labels
No labels