Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to add credentials from the command line using 'git credential-osxkeychain store'?

Tags:

git

macos

When executing 'git credential-osxkeychain' in MacOS, it shows the option 'store' and I guess it can be used to add the credentials.

I didn't find any documentation about the syntax required to add credentials using the command 'git credential-osxkeychain store', anyone knows how to do it?

Please notice that I do know how to do it using the MacOS app 'Keychain Access', I'd like to know how to do it using the command line

like image 932
tvs Avatar asked Nov 21 '18 20:11

tvs


People also ask

What is git credential Osxkeychain?

If you're using a Mac, Git comes with an “osxkeychain” mode, which caches credentials in the secure keychain that's attached to your system account. This method stores the credentials on disk, and they never expire, but they're encrypted with the same system that stores HTTPS certificates and Safari auto-fills.

What is credential in git?

Git has an internal interface for storing and retrieving credentials from system-specific helpers, as well as prompting the user for usernames and passwords. The git-credential command exposes this interface to scripts which may want to retrieve, store, or prompt for credentials in the same manner as Git.


1 Answers

git credential-osxkeychain store reads protocol/host/username/password from stdin separated by newlines, so feed them something like this:

echo "\
protocol=https
host=github.com
username=$NAME
password=$PASSWD" | git credential-osxkeychain store

All 4 parameters are required.

like image 191
phd Avatar answered Oct 21 '22 20:10

phd