I wrote a shell script to do project releasing with Git
, in the shell script I first cd
to the Git working copy and then do git pull origin master
.
But it prompts me for password: git@localhost's password:
, this's annoying, and I'm wondering if I can indicate the password for git pull
in the script, like this:
git pull origin master --password abcd123
Any idea?
相关问题
- How to get the return code of a shell script in lu
- Invoking Mirth Connect CLI with Powershell script
- Why does recursive submodule update from github fa
- Extended message for commit via Visual Studio Code
- Emacs shell: save commit message
Generally: Don't put passwords into scripts and especially don't supply them with command arguments because that means they are published via the
ps
command to anyone on the same computer.The solution here is to use ssh and run an ssh agent. The agent loads your private key and supplies that to the shell script when it tries to connect to the remote side via SSH. That way, you only need to give your pass phrase to the agent.
This blog post should give you more details: Password-less logins with OpenSSH
If you're using Windows, putty comes with the same functionality.