Skip to content

Use custom ssh key cannot clone #725

Closed
@ghost

Description

#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('git@github.com:somebody/someproject','test')

output:

DEBUG:git.cmd:Popen(['git', 'clone', '-v', 'git@github.com:somebody/someproject', 'test'], cwd=/root/test/wel, universal_newlines=True, shell=None)
DEBUG:git.repo.base:Cmd(['git', 'clone', '-v', 'git@github.com: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('git@github.com: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 git@github.com:somebody/someproject test
  stderr: 'Permission denied (publickey).
fatal: The remote end hung up unexpectedly

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions