Introduction
Git access includes to authenticate with the Git Server and to access remote repositories.
The steps to set up Git Access
Manual Configuration
Git Configuration File
A Git client reads configuration items from the following file (assuming a user account me
):
- for Unix environments
/home/me/.ssh/config
- for Windows environments
C:\Users\me\.ssh\config
The Git config
file can look like this:
Host github.com Hostname github.com IdentityFile C:\Users\me\.ssh\github_rsa IdentitiesOnly yes
Explanation:
- The settings map use of a specific private key file to authentication with a specific Git Server.
Git Configuration Items
A typical configuration step performed with a Git client looks like this:
# Specify user name git config --global user.name "My Account" # Specify e-mail address git config --global user.email "myAccount@example.com" # Use simple merge strategy git config --global push.default simple
Automation with the JS7 PowerShell Module
Users who whish to automate the steps to set up Git access can use the following resources:
- The JS7 - REST Web Service API allows to perform the same operations for Git integration as offered from the JOC Cockpit GUI.
- The JS7 - PowerShell Module offers simplified access to the REST Web Service API for scripting purposes.
- The PowerShell examples when executed might prove to be instructive for logging of REST API calls when used with the
-debug
option.
- The PowerShell examples when executed might prove to be instructive for logging of REST API calls when used with the
Find the documentation for related cmdlets from PowerShell CLI 2.0 - Cmdlets - Git Repository Integration.
FEATURE AVAILABILITY STARTING FROM RELEASE 2.3.0
The Add-JS7GitCredentials
cmdlet allows to store Git credentials with JOC Cockpit like this
# parameterization $gitServer = 'github.com' $gitAccount = 'myAccount' $gitUserName = 'My Account' $gitUserMail = 'myAccount@example.com' $gitKeyFile = 'myKey.rsa' # use of private key file Add-JS7GitCredentials -Server $gitServer -Account $gitAccount -KeyFile $gitKeyFile -UserName $gitUserName -UserMail $gitUserMail # use of access token (similarly insecure as use of passwords) # Add-JS7GitCredentials -Server $gitServer -Account $gitAccount -AccessToken 'a1b2c3d4e5f6g7h8' -UserName $gitUserName -UserMail $gitUserMail # use of password (denied by a larger number of Git Servers) # Add-JS7GitCredentials -Server $gitServer -Account $gitAccount -Password (ConvertTo-SecureString 'secret' -AsPlainText -Force) -UserName $gitUserName -UserMail $gitUserMail # remove Git credentials Remove-JS7GitCredentials -Server $gitServer
Explanation:
- Line 2-6: Parameters used by the subsequent examples.
- Line 10: A private key file is specified. This file has to exist and is expected in the