Provide password for git in shell script, without ssh?

I wrote a shell script to create a project with Git , in the shell script I first cd to a working copy of Git, and then run git pull origin master .
But it tells me the password: git@localhost password: this is annoying, and I wonder if I can specify the password for git pull in the script, for example:
git pull origin master --password abcd123
Any idea?

+4
source share
1 answer

In general: do not put passwords in scripts and, especially, do not provide them with command arguments, because this means that they are published using the ps command to everyone on the same computer.

The solution here is to use ssh and start the ssh agent. The agent loads your private key and delivers it to the script shell when it tries to connect to the remote side via SSH. Thus, you only need to pass your pass-phrase to the agent.

This blog post should contain more detailed information: Password without logging in with OpenSSH

If you use Windows, putty comes with the same functionality.

+3
source

Source: https://habr.com/ru/post/1400168/


All Articles