Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use custom ssh key cannot clone #725

Closed
ghost opened this issue Feb 14, 2018 · 1 comment
Closed

Use custom ssh key cannot clone #725

ghost opened this issue Feb 14, 2018 · 1 comment

Comments

@ghost
Copy link

ghost commented Feb 14, 2018

#690
After solve the fetch/pull error, I found that I still can not clone from remote.

os.environ['GIT_SSH_COMMAND'] = 'sudo ssh -v -i /root/key'
with Git().custom_environment(GIT_SSH_COMMAND=os.environ['GIT_SSH_COMMAND']):
	repo = Repo.clone_from('[email protected]:somebody/someproject','test')

output:

DEBUG:git.cmd:Popen(['git', 'clone', '-v', '[email protected]:somebody/someproject', 'test'], cwd=/root/test/wel, universal_newlines=True, shell=None)
DEBUG:git.repo.base:Cmd(['git', 'clone', '-v', '[email protected]:somebody/someproject', 'test'])'s unused stdout: Initialized empty Git repository in /root/test/.git/

DEBUG:git.cmd:AutoInterrupt wait stderr: 'Permission denied (publickey).\nfatal: The remote end hung up unexpectedly\n'
Traceback (most recent call last):
  File "test.py", line 7, in <module>
    repo = Repo.clone_from('[email protected]:somebody/someproject','test')
  File "/usr/local/lib/python2.7/site-packages/git/repo/base.py", line 982, in clone_from
    return cls._clone(git, url, to_path, GitCmdObjectDB, progress, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/git/repo/base.py", line 933, in _clone
    finalize_process(proc, stderr=stderr)
  File "/usr/local/lib/python2.7/site-packages/git/util.py", line 336, in finalize_process
    proc.wait(**kwargs)
  File "/usr/local/lib/python2.7/site-packages/git/cmd.py", line 418, in wait
    raise GitCommandError(self.args, status, errstr)
git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
  cmdline: git clone -v [email protected]:somebody/someproject test
  stderr: 'Permission denied (publickey).
fatal: The remote end hung up unexpectedly
@Byron
Copy link
Member

Byron commented Feb 24, 2018

I would think creating a temporary instance of the Git command helper does not affect the clone_from call at all.

Instead you probably want to pass the environment directly when cloning as described in the docs.

I am closing this one assuming that will work for you. But please feel free to comment if that's not the case and it might be reopened.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant