Skip to content

Cloning repository with SSH url #272

Closed

Description

@amackera

Hello! Let me prefix this by pointing out that I don't know much about git, libgit2, or pygit2, so please forgive me if this issue is absurd.

It seems to me that pygit2 breaks when trying to clone repositories from "SSH" URLs.

The following code will result in a segmentation fault from the most recent pygit2 package from pip:

from pygit2 import clone_repository

if __name__ == '__main__':
    repo = clone_repository(
        'git@github.com:libgit2/pygit2.git',
        'pygit2')

However the HTTP URL works as expected. Is this intended behavior?

Activity

  1. carlosmn commented on Sep 25, 2013

    @carlosmn
    Member

    That libgit2 version has a bug where it will try to call the callback to get authentication information regardless of whether it's set, which means not setting it will cause a segfault.

  2. amackera commented on Sep 25, 2013

    @amackera
    Author

    @carlosmn Interesting. When you say "authentication information", what do you mean specifically?

  3. carlosmn commented on Sep 25, 2013

    @carlosmn
    Member

    Either a username-password or username-public/private-key combination, which you always need when talking to ssh.

  4. bunjiboys commented on Oct 24, 2013

    @bunjiboys

    So I have been looking at trying to clone using SSH as well, but I cannot figure out how to get pygit2 to use public key authentication. Does anyone have an example python code snippet for clone_repository using SSH and public key authentication?

  5. bunjiboys commented on Oct 31, 2013

    @bunjiboys

    @amackera The segfault is due to problems in libgit2 where it doesnt parse the string correctly, in the current master branch. I just submitted a PR to pygit2 that adds full public key support to pygit2, where you specify the SSH keypair to use. See #282 for more info.

    But the fast fix to the segfault is to use this format instead for the repo url: ssh://github.com/bunjiboys/pygit2.git as this format is parsed correctly.

  6. carlosmn commented on Mar 31, 2014

    @carlosmn
    Member

    The fixed version of the library has been available for some time.

  7. hexaJer commented on Apr 10, 2014

    @hexaJer

    I do not find how use it.
    I built successfully libgit2 (libgit2/libgit2@bcc6229) and pygit2 (d882af8) and I tried :

    >>> repo = init_repository("/servers/data_server/home/jclement/test")
    >>> remote = repo.create_remote("origin","ssh://repo/projects/tests/test.git")
    >>> cred = Keypair("jclement",id_rsa_pub,id_rsa,"")
    >>> remote.credentials = cred
    >>> remote.fetch()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    _pygit2.GitError: This transport isn't implemented. Sorry
    

    did I forget something?

  8. carlosmn commented on Apr 10, 2014

    @carlosmn
    Member

    Libgit2 needs to be build with ssh support. That is, it needs to find the openssh2 library headers and pkg-config info at build-time.

  9. hexaJer commented on Apr 11, 2014

    @hexaJer

    okay I had not seen !
    Thanks !

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

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