jual ahmed
jual ahmed

Reputation: 448

How do I disable asking password when doing git push/pull to vps server?

Is there any way to set server password with local git repository? when every time i push to serve it's ask me to provide password. i want to make it's automatic with one time config.

Upvotes: 1

Views: 925

Answers (3)

yathomasi
yathomasi

Reputation: 548

git provides storage of the credential

$ git config credential.helper store
$ git push http://example.com/repo.git
Username: <type your username>
Password: <type your password>

[several days later]
$ git push http://example.com/repo.git
[your credentials are used automatically]

it basically does is store the credential in .git-credentials file https://user:[email protected] check these official docs: git credential store and Credential Storage

Upvotes: 0

VonC
VonC

Reputation: 1324337

It depends on your URL (git remote -v inside your local repository to show it)

  • HTTPS means you need to activate a credential caching setting
  • SSH means it asks you for the passphrase which does protect the private key (you need to cache it with an SSH agent)
    Or: you did not add the public key to the server account ~/.ssh/authorized_keys file, and SSH falls back to that server account password.

Upvotes: 2

beli3ver
beli3ver

Reputation: 405

Look at your .git/config file. The remote part will look like this:

[remote "origin"]
    url = https://url.tld

Change it to

[remote "origin"]
    url = git@url:/path/on/server

Then it will use SSH. You can copy your SSH Key to the server and never will be asked for a password again

Upvotes: 0

Related Questions