Project

General

Profile

GitCredentials » History » Revision 3

Revision 2 (Tech-X Corporation, 06/27/2019 05:19 PM) → Revision 3/5 (Tech-X Corporation, 06/28/2019 11:28 AM)

# Git Credentials 

 Private git repos require a username and password to clone and to push. 

 In the near future, bilder may require access to private git repos.   

 This document details how to cache your git credential so that you do not have to enter them interactively, and so that bilder will not fail to clone required git repositores.   

 You should store your git credentials as soon as possible on all machines where you expect to run bilder. 

 ## Login directory 

 ~ refers to the login, or home, directory.    In some cases, git does not expand ~, ~/.git-credentials on Windows, Linux and therefore will request interactive entry Mac 
  
 The location of credentials.    For this reason, these instructions use the explicit home directory instead of ~.    Git documentation does refer to ~, but this does not work for accessing github.com credentials. 

 ## Windows 

 Open a Cygwin terminal.    To find your login directory, enter  


 > pwd 

 
 Your login directory should be /winsame/{username}. 

 Create the file /winsame/{username}/.git-credentials containing line(s) of the form: 

 > https://username:password@server.com 


 For ice.txcorp.com, where Tech-X git repos will be stored, the line will be: 

 > https://username:password@ice.txcorp.com 

 If you have a github.com account, you may cache your github.com credentials in is the same file: 

 > https://username:password@ice.txcorp.com 
 > https://github_username:github_password@github.com 

 Because this is a plain text file containing your password(s), change permissions of the file so only you can read it: 

 > chmod 600 ~/.git-credentials 

 ### Configure git to use .git-credentials 

 git may be configured to check .git-credentials for all repos (--global), or for a single git repo. 

 To configure for global access, use the command: 

 > git config --global credential.helper 'store --file=/winsame/{username}/.git-credentials' 

 This command adds lines to /winsame/{username}/.gitconfig: 

 > [credential] 
 >           helper = store --file=/winsame/{username}/.git-credentials 

 To configure git to check .git-credentials for a specific clone or master 

 cd to the clone Windows, Linux and execute 

 > git config credential.helper 'store --file=/winsame/{username}/.git-credentials' 

 This command modifies Mac.    It is the file /winsame/{username}/.git-credentials: 

 > {clone}/.git/config 


 ## Linux 

 Open a terminal. ~/.git-credentials.    To find ~ is your login directory, enter  

 > pwd 

 Your login directory should be /home/research/{username}. or home directory.    If it is different, note bilder will check for the login directory and modify existence of this file. 

 On all of the instructions below above platforms where you expect to run bilder, create .git-credentials 

 Create the file /home/research/{username}/.git-credentials containing line(s) of the form: ~/.git-credentials with one line for each server: 

 > <pre> 
 https://username:password@server.com 
 </pre> 

 For ice.txcorp.com, where Tech-X git repos will be stored: 

 > <pre> 
 https://username:password@ice.txcorp.com 
 </pre> 

 If you have a github.com account, you may cache your github.com credentials in the same file: 

 > <pre> 
 https://username:password@ice.txcorp.com 
 > https://github_username:github_password@github.com 


 
 </pre> 

 Because this is a plain text file containing your password(s), change permissions of the file so only you can read it: 

 > <pre> 
 chmod 600 ~/.git-credentials 
 </pre> 

 ### ##    Configure git to use .git-credentials check ~/.git-credentials 

 git may be configured to check ~/.git-credentials for all repos (--global), or for a single git repo. 

 > git config --global credential.helper 'store --file=/home/research/{username}/.git-credentials' 

 This command adds lines to /home/research/{username}/.gitconfig: 

 > [credential] 
 >           helper = store --file=/home/research/{username}/.git-credentials 


 To configure git to check .git-credentials for a specific clone or master 

 cd to globally, execute the clone and execute 

 > git config credential.helper 'store --file=/home/research/{username}/.git-credentials' 


 This following command modifies the file: 

 > {clone}/.git/config 


 ## in a  
  * Windows - cygwin window 
  * Linux - terminal 
  * Mac - terminal 

 Open a terminal.    To find your login directory, enter  

 > pwd 

 Your login directory should be /home/research/{username}.    If it is different, note the login directory and modify the instructions below to create .git-credentials 

 Create the file /home/research/{username}/.git-credentials containing line(s) of the form: 

 > https://username:password@server.com 

 For ice.txcorp.com, where Tech-X git repos will be stored: 

 > https://username:password@ice.txcorp.com 

 If you have a github.com account, you may cache your github.com credentials in the same file: 

 > https://username:password@ice.txcorp.com <pre> 
 > https://github_username:github_password@github.com 

 Because this is a plain text file containing your password(s), change permissions of the file so only you can read it: 

 > chmod 600 ~/.git-credentials 

 ### Configure git to use .git-credentials 

 git may be configured to check ~/.git-credentials for all repos (--global), or for a single git repo. 

 > git config --global credential.helper 'store --file=/home/research/{username}/.git-credentials' --file=~/.git-credentials' 
 </pre> 

 This command adds lines to /home/research/{username}/.gitconfig: ~/.gitconfig: 

 > <pre> 
 [credential] 
 >           
         helper = store --file=/home/research/{username}/.git-credentials --file=~/.git-credentials 
 </pre> 

 To configure ##    Configure git to check .git-credentials ~/.git-credentials for a specific clone or master 

 cd to the clone and execute 

 > <pre> 
 git config credential.helper 'store --file=/winsame/{username}/.git-credentials' --file=~/.git-credentials' 
 </pre> 

 This command modifies the file: 

 > <pre> 
 {clone}/.git/config 


 ### 
 </pre> 

 ## Mac Keychain 

 The default credential.helper for Mac OS X is Keychain application.    git refers to this as *osxkeychain*. 

 If you are using bilder on a Mac, git will check for credentials in *osxkeychain*. 

 If you have additionally configured git to check ~/.git-credentials, it will check for the server credentials in that file. 

 When git first uses the credentials in ~/.git-credentials, it will automatically create a Keychain internet password entry using the credentials in ~/.git-credentials. 

 ### ## Checking for server credentials in Keychain 

 You may check on the command line for the existence of a stored credential in Keychain: 

 > <pre> 
 security find-internet-password -s github.com 
 </pre> 

 The result of this command will be 
  * 0 - server credential found in keychain 
  * 44 - server credential not found in keychain