Forum Archive

Cloning from Github repo with SSH key auth (using StaSh toolset)

scrimple

Just wanted to know if anyone's gotten git-clone working against a github repo of theirs using some kind of auth method?

(Edit: I'm using the latest StaSh set of tools from ywangd/stash and the vanilla gittle, dulwich packages from jsbain)

The current stash/bin/git.py utility doesn't include anything in the auth kwarg by default, so I first tried hacking it by modifying the method to include:

auth=gittle.GittleAuth(username="me", pkey=(os.path.join(os.environ['HOME'], '.ssh/pkey')))

... and adding auth=auth to the Gittle.clone() call, but that returns a duplicate keyword error. Finding this annoyingly hard to debug or fix. What am I doing wrong, here?

ccc

What happens when you set auth but do not add auth=auth?

scrimple

Using it straight with the ~/.ssh/config set and keys available, only passes back SSHException "Authentication Method Not Available" (from paramiko, I believe, but it would help if there were verbose modes to see the full traceback)

ccc

Do you have https://workingcopyapp.com ?

scrimple

I do not. Been burnt by too many git client clones on the app store before, but thanks for the recommendation. Is there a decent method for connecting it to pythonista?

ccc

https://github.com/cclauss/Pythonista-and-Working-Copy for now but see https://forum.omz-software.com/topic/4134/appstore-rule-change on the potential for future improvements.

JonB

Strangely, all of my git ssh keys in pythonista seemed to stop working recently . Don't know what that's all about, but the following did fix the issue:

1) I deleted my existing keys in ~/.ssh If you use ssh in stash for other things, this could be a problem, in which case go into github and delete your keys.

2)

[~/Documents]$ gh create_key newipadkey
Creating a ssh key in ~/.ssh/
ssh-keygen -d rsa -b2048
ssh keys generated with rsa encryption

[~/Documents]$ git clone ssh://git@github.com/jsbain/stash.git stash

And this successfully cloned.

It is possible you may need to add github to known hosts (copy the following to your ~/.ssh/known_hosts file) if you havent before

github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
JonB

By the way, in stash you can use

stashconf py_traceback 1

to print full tracebacks, and

stashconf py_pdb 1

to automatically start interactive pdb when exceptions occur.
These turn out to be not very useful for troubleshooting dulwich auth issues.

For paramiko issues, you could, in the 2.7 interpreter in the console, type

import paramiko
paramiko.util.log_to_file('paramikolog.txt')

(this has to be the 2.7 interpreter, because stash runs in 2.7 by default)

This forces paramiko to log to the above named file, which you can open in the editor and see what is happening. With my old key(s) i was getting the super helpful

DEB [20170618-07:37:36.987] thr=2   paramiko.transport: Trying discovered key cb06eb8641f4ca3ff73f806d8bdd7c22 in /private/var/mobile/Containers/Shared/AppGroup/C534C622-2FDA-41F7-AE91-E3AAFE5FFC6B/Pythonista3/.ssh/id_rsa
DEB [20170618-07:37:37.075] thr=1   paramiko.transport: userauth is OK
INF [20170618-07:37:37.581] thr=1   paramiko.transport: Authentication (publickey) failed.

I had to delete the offending key before it would move onto another one.

JonB

i should also mention that the gh command does require that you have your github https user/pass stored in the keychain (see help for gh command), which could be set up by running clone at least once using https, then running push.