Forums

Setting up github access not to need passphrase.

First, I am using a paid account.

Second, I can successfully connect to github via ssh, however it requires me to type my passphrase every time. I would like to be able to avoid that.

Help for github suggests the use of ssh-agent by editing ~/.ssh/config with the line:

Host example.com ForwardAgent yes

(editing example.com with the appropriate name). I tried ssh.pythonanywhere.com which did not work. I found one set of suggestions in a previous thread but it seemed more complex than should be necessary and was four years old.

Thanks for any suggestions.

Just adding an ssh agent line is not enough. Check out the GitHub docs here: https://help.github.com/articles/connecting-to-github-with-ssh/

I had, in fact, found that page as well as all links and also scoured the Stack Overflow articles. I can successfully execute:

ssh -T git@github.com

Attempt to SSH in to github

Hi username! You've successfully authenticated, but GitHub does not provide shell access.

which was their suggested test and I have verified I can pull down the contents of my git repository using ssh. The only remaining obstacle is the fact that I can only accomplish these by typing in my passphrase every time. The main motivation for using ssh instead of http was to avoid having to retype my github password which was necessary using that route, but my passphrase is longer than that!

I am basing my steps on:

https://developer.github.com/v3/guides/using-ssh-agent-forwarding/

What steps do you think I am missing?

Cheers,

Lyman

I think all you need to do is set up an ssh key with no passphrase. When you generate the key, for example by running this command on PythonAnywhere:

ssh-keygen -t rsa

...then it generates two files, a private key and a public key. It will ask you for a passphrase -- if you just hit return when it does that, the private key will have no passphrase. If you enter a key, then the private key will be protected with that passphrase.

So if you generate a key with no passphrase, then add the public key (by default ~/.ssh/id_rsa.pub) to your github settings, then you'll be able to access your repositories without needing to enter anything.

Use a passphrase.

Setting up a ssh without a passphrase is OK if you're on your own server - this way only you have access to the private key. Howefver, when you generate the key/pair in pythonanywhere the public key is in ~/.ssh on pythonanywhere. Also, ALL your Github projects are open to that ssh key access (I don't know if you can limit ssh to a specific project). One way if you're a paying account is to use ssh-agent to store the passphrase and hand it over to ssh when you're connecting. You need to create a console and keep it alive for this purpose. That's what I've done. To do this:

eval "$(ssh-agent -s)" ssh-add ~/.ssh/id_rsa

I'm assuming your PRIVATE key is in ~/.ssh/id_rsa

If you choose to name your key when you create it, you use the -i /path/to/private/key option, or create a config. See the following article: https://www.cyberciti.biz/faq/force-ssh-client-to-use-given-private-key-identity-file/

So, use a passphrase, it's the best way to do things securely.