-1

I've a tricky problem in my project. I have an application runs on VDS. I installed this application with git and composer. This project have git repository just like local one.

I'm trying to make an auto updater bot.This bot is going to get last commit/tag from gitlab and fetch it.

I can use nodejs or php cron job to do.

But git pull command asks for my username and password. I cant install php_expect extension. Tried this yuloh/expect library but it didn't catch username input.

So here is my question: How and which method should i implement for run this git pull command and pass username and password?

2 Answers2

1

Solved

For getting new updates...

git pull https://username:password@gitprovider/vendor/repository "version_code":"version_code"


For merging updates with the end-user application.

git merge "version_code":master

this two together completely updates app with new version.

About password protection, we'r going to use ioncube for cron file.

Community
  • 1
  • 1
  • And that what I pruposed but didn't recommend for security reasons, mark my answer as accepted if u want! –  Oct 03 '18 at 14:52
-1

if I fully understanded your question you can try this:

  • you can put the password in .netrc file (_netrc on windows). From there it would be picked up automatically. It would go to your home folder with 600 permissions.

  • you could also just clone the repo with https://user:pass@domain/repo but that's not really recommended as it would show your user/pass in a lot of places...

  • a new option is to use the credential helper. Note that credentials would be stored in clear text in your local config using standard credential helper. credential-helper with wincred can be also used on windows.

Usage examples for credential helper

git config credential.helper store - stores the credentials indefinitely.
git config credential.helper 'cache --timeout=3600'- stores for 60 minutes

For ssh-based access, you'd use ssh agent that will provide the ssh key when needed. This would require generating keys on your computer, storing the public key on the remote server and adding the private key to relevant keystore.