indicate a password for git pull in shell script,

2019-04-10 04:20发布

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?

标签: git shell
1条回答
Bombasti
2楼-- · 2019-04-10 05:10

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.

查看更多
登录 后发表回答