Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
.netrc file so you can push/pull to https git repos without entering your creds all the time
machine github.com
login technoweenie
password SECRET
machine api.github.com
login technoweenie
password SECRET
@technoweenie

This comment has been minimized.

Show comment Hide comment
@technoweenie

technoweenie Jul 8, 2011

Stick this in ~/.netrc with chmod 600 or something. You can curl the api as yourself with curl -n https://api.github.com/user

Owner

technoweenie commented Jul 8, 2011

Stick this in ~/.netrc with chmod 600 or something. You can curl the api as yourself with curl -n https://api.github.com/user

@noamtm

This comment has been minimized.

Show comment Hide comment
@noamtm

noamtm Jan 7, 2013

What about per-repository login?

noamtm commented Jan 7, 2013

What about per-repository login?

@g2p

This comment has been minimized.

Show comment Hide comment
@g2p

g2p Mar 20, 2013

@noamtm I just checked, netrc or gitcredentials aren't up to the task (the latter has an option to match on host paths, but prefix matches are missing so it's only semi-convenient). If you control the url you should put the username in the url or use host aliases, both ssh (man ssh_config) and git (git help config then /insteadof) have them; if you can't (go get or pip remote requirements), there is no convenient solution.

g2p commented Mar 20, 2013

@noamtm I just checked, netrc or gitcredentials aren't up to the task (the latter has an option to match on host paths, but prefix matches are missing so it's only semi-convenient). If you control the url you should put the username in the url or use host aliases, both ssh (man ssh_config) and git (git help config then /insteadof) have them; if you can't (go get or pip remote requirements), there is no convenient solution.

@madarche

This comment has been minimized.

Show comment Hide comment
@madarche

madarche Dec 23, 2013

Note about a limitation: password in .netrc file should not contain spaces, since the .netrc file is parsed against spaces, tabs and new-lines.

Note about a limitation: password in .netrc file should not contain spaces, since the .netrc file is parsed against spaces, tabs and new-lines.

@soupdiver

This comment has been minimized.

Show comment Hide comment
@soupdiver

soupdiver Jul 9, 2014

Thanks man! Exactly what I needed

Thanks man! Exactly what I needed

@kprikshit

This comment has been minimized.

Show comment Hide comment
@kprikshit

kprikshit May 1, 2015

Any way to store password here not in plain text.
It's too risky to store in plaintext

Any way to store password here not in plain text.
It's too risky to store in plaintext

@snowyu

This comment has been minimized.

Show comment Hide comment
@snowyu

snowyu Jul 24, 2015

github supports the access token instead of password: https://help.github.com/articles/creating-an-access-token-for-command-line-use/

snowyu commented Jul 24, 2015

github supports the access token instead of password: https://help.github.com/articles/creating-an-access-token-for-command-line-use/

@rhiann0n

This comment has been minimized.

Show comment Hide comment
@rhiann0n

rhiann0n Feb 3, 2016

With respect, I would definitely recommend authenticating to github using ssh with decryption key instead of the .netrc method, as it's insecure: https://help.github.com/articles/generating-an-ssh-key/

rhiann0n commented Feb 3, 2016

With respect, I would definitely recommend authenticating to github using ssh with decryption key instead of the .netrc method, as it's insecure: https://help.github.com/articles/generating-an-ssh-key/

@andrewspiers

This comment has been minimized.

Show comment Hide comment
@andrewspiers

andrewspiers Feb 7, 2017

@rhiannon that's all good until you are somewhere that blocks 22 outbound.

@rhiannon that's all good until you are somewhere that blocks 22 outbound.

@felipe1982

This comment has been minimized.

Show comment Hide comment
@felipe1982

felipe1982 Mar 14, 2017

@andrewspiers I thought that you can alternatively use port 443 outbound for SSH traffic... Or am I confused with bitbucket...?

@andrewspiers I thought that you can alternatively use port 443 outbound for SSH traffic... Or am I confused with bitbucket...?

@miradnan

This comment has been minimized.

Show comment Hide comment
@miradnan

miradnan Mar 23, 2018

Thanks! Exactly what I needed

miradnan commented Mar 23, 2018

Thanks! Exactly what I needed

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