Where to put .netrc


#1

I’m using Cloud9 to work on a project that is to be uploaded to GitHub, and it is annoying to have to enter username and password every time I do a git push. On my PC, I fix this by putting my username and password into a file called .netrc, which is then used to automatically supply the username and password.

Three related questions:

  1. Is this possible to do on Cloud 9?
  2. If so, where should the file .netrc be placed?
  3. Is this a dangerous thing to do on Cloud 9?

#2

Run the following in your bash terminal:
git config --global credential.helper ‘cache --timeout 86400’

That’ll remember your github credentials for a day - so you don’t have to keep entering them every single time.


#3

If possible, try to use SSH urls, as they are far more secure and much easier to use.

A much simpler solution that doesn’t require you to enter your password every time is to switch to using SSH URLs, which you can find by going to your GitHub repository, clicking “Clone or Download”, then “Use SSH”, and copying the link (should look like git@github.com:username/repository.git). Then go to your terminal and type git remote set-url origin <SSH link here>. The last step is to add your public key to GitHub. The simplest way to do this is by connecting your Cloud9 account to GitHub from here, or you can add it manually without linking accounts by running c9 open ~/.ssh/id_rsa.pub, copying the contents, and adding them in your GitHub settings.

(Yes, I copied this from another one of my posts)


#4

Hi all I have a related ? Here and prolly should be on github but it is so close to this I hope it is cool.
Do I have to create a new key for every project? I already have allowed github and I still have to put in my u/p every time. What am I doing wrong here. Any help would be appreciated.


#5

Can you make sure you’re using the correct type of URL by running git remote -v in the terminal, and making sure the URLS are in the format git@github.com:username/repository.git. If that’s the case, make sure you have the correct Public Key saved on GitHub (it should be named C9 or Cloud9 if you linked you GitHub account to Cloud9).