0

I want to not type my username and password every time when work with something git, so my ssh config is:

Host gitlab.com
   HostName gitlab.com
   PreferredAuthentications publickey
   IdentityFile /root/.ssh/id_rsa_gitlab
   IdentitiesOnly yes


Host github.com
   HostName github.com
   PreferredAuthentications publickey
   IdentityFile /root/.ssh/id_rsa
   IdentitiesOnly yes

I makes 2 different rsa keys, add pub keys to github and gitlab, but it keep asking me login and pass, pls can someone help me with it?

  • It's asking me on only https protocol i think, tryed to git clone git@gitlab.com:some/some.git and it's not ask my password, so how to fix that? – Satont Worldwide Dec 20 '17 at 00:56

2 Answers2

0

Git provides two methods to reduce this repitition:

  1. Static configuration of usernames for a given authentication context.

  2. Credential helpers to cache or store passwords, or to interact with a system password wallet or keychain.

The first is simple and appropriate if you do not have secure storage available for a password. It is generally configured by adding this to your config:

[credential "https://example.com"] username = me

Credential helpers, on the other hand, are external programs from which Git can request both usernames and passwords; they typically interface with secure storage provided by the OS or other programs.

To use a helper, you must first select one to use. Git currently includes the following helpers:

cache - Cache credentials in memory for a short period of time. store - Store credentials indefinitely on disk.

Please go through this for detailed info: https://git-scm.com/docs/gitcredentials

ParthS007
  • 2,581
  • 1
  • 22
  • 37
0

Navigate to the project directory and type git config --list.

If remote.origin.url looks like https://gitlab.com/gitlab-org/gitlab-ce.git, you will need to change it to the one that looks like git@gitlab.com:gitlab-org/gitlab-ce.git. This can be found on the main page of any project on GitLab.

Use git-remote to set the new URL.

git remote set-url origin git@gitlab.com:gitlab-org/gitlab-ce.git

This answer shows an example of the process.