简体   繁体   中英

how to securely store git https password

I need to have a crontab entry that pushes changes to a remote git repo.

The remote is currently specified as:

origin https://username@server/git/repo.git (push)

My crontab entry would then do: git push

How can I disable the need for asking for a password?

You need to create a .netrc file in your home directory. Nobody without root access can read from your home directory. Search for .netrc file, because .netrc configuration changes according to your host server.

But generally it goes like this:

 machine your.host.server.com
 login yourUserName
 password yourPassWord

As Charlie said, you just need to:

  1. Generate an SSH key pair ( ssh-keygen -t rsa -b 4096 -C "$(whoami)@$(hostname)-$(date -I)" )
  2. Upload it to bitbucket ( just your public key )
  3. Write the script that, thanks to the SSH keys, will not prompt you for any password any more during any git operations involving bitbucket (ie pull, push, fetch..)

You should be set if you just want to not be prompted a password. If you want to still use HTTPS, I am not sure how to.

Just make sure that you use the correct notation for the push and pull (it is different when you use HTTPS or SSH, notably you access the URL with git@bitbucket.org:<username>/<reponame>.git )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM