

Remember that "store" based git-credential-helper stores passwords & values in plain-text. Where you may choose to set the ALICE_GITHUB_PASSWORD environment variable from a previous shell command or from your pipeline config etc. Git config -global credential.helper "store -file $" # Or you may choose to not specify GIT_CREDS_PATH at all. If you're using http/https and you're looking to FULLY AUTOMATE the process without requiring any user input or any user prompt at all (for example: inside a CI/CD pipeline), you may use the following approach leveraging git credential.helper GIT_CREDS_PATH="/my/random/path/to/a/git/creds/file" Note that I'm no pro, so the above may not be secure in the sense that no trace would be left for any sort of forensic work. However, it may be easier to just prepend all the above commands with a space in order to prevent them being stored to begin with. There are many ways to do this, see this question and this question.

If you don't need the repo again, delete it rm -rf.You probably don't want to leave that token hanging around if you have no intentions of using it for some time, so go back to the tokens page and hit the delete button next to it.Not all of this may be necessary, depending on how sensitive what you're doing is. If you want to clone it to a specific folder, just insert the folder address at the end like so: git clone, where is, you guessed it, the folder to clone it to! You can of course use. Same as the command gave, git clone just replace, and with whatever your info is. Copy your new token before you leave the page.Set a description/name for it, check the "repo" permission and hit the "Generate token" button at the bottom of the page.
#Git clone command username password password#
Click "Generate a New Token" and enter your password again.Go to Settings > Developer Settings > Personal Access Tokens ( here's a direct link).
#Git clone command username password how to#
GitHub has a whole guide here on how to get a token, but here's the TL DR. This is obviously a security risk for almost every use case, but since I plan on deleting the repo and revoking the token when I'm done, I don't care. It warns that adding the token to the clone URL will store it in plaintext in. GitHub has a very handy guide on how to do this, but it doesn't cover what to do if you want to include it all in one line for automation purposes. I thought I would expand on how to do that, in case anyone comes across this answer like I did while trying to automate some cloning. In the comments of answer, mentioned that you can use git clone to clone from GitHub at the very least. The above will cause Git to ask for your password once every 15 minutes (by default). For example: git config -global credential.helper cache To securely store your password when using HTTP, use a credential helper.

WARNING: Adding your password to the clone URL will cause Git to store your plaintext password in. Some services provide HTTP access as an alternative to ssh:

Git clone gh-bar:bar/bar.git # logs in with account bar You would then clone the two repositories as follows: git clone gh-foo:foo/foo.git # logs in with account foo You would add the following to your ~/.ssh/config: Host gh-foo You want to access with your foo account and with your bar account. Your ssh key for foo is ~/.ssh/foo_github_id and your ssh key for bar is ~/.ssh/bar_github_id. To pick which account you want to log in as, you have to tell ssh which private key to use.įor example, suppose you had two GitHub accounts: foo and bar. If you have multiple accounts at a place like GitHub or Heroku, you'll have multiple ssh keys (at least one per account). Choosing between multiple accounts at GitHub (or Heroku or.) Also see Configuring Git over SSH to login once, GitHub's help page on ssh key passphrases, gitolite's ssh documentation, and Heroku's ssh keys documentation. If you don't want to type your ssh password all the time, the typical solution is to generate a public/private key pair, put the public key in your ~/.ssh/authorized_keys file on the remote server, and load your private key into ssh-agent. Use ssh-agent to avoid typing passwords all the time Git has no way to pass a password to ssh, because ssh might not even use a password depending on the configuration of the remote server. From git help clone:Īn alternative scp-like syntax may also be used with the ssh part before the is the username, and the authentication method (password, public key, etc.) is determined by ssh, not Git. The format tells Git to use ssh to log in to host with username user.
