Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Integrating GitHub Enterprise With SSH and Tokens

DZone's Guide to

Integrating GitHub Enterprise With SSH and Tokens

Working on a project? Here is a quick way to integrate GitHub Enterprise to it via SSH and tokens.

Free Resource

Build APIs from SQL and NoSQL or Salesforce data sources in seconds. Read the Creating REST APIs white paper, brought to you in partnership with CA Technologies.

Quick Start Guide

Log into GitHub.yourOrganisation.com enterprise and request getting access to the organization.

Fork the GitHub yourOrganisation-API Repository to your GitHub Account.

SSH

Checking for existing SSH keys Lists the files in your .SSH directory, if they exist.

akhilesh@AKHILESHPC MINGW64 /
$ ls -al ~/.ssh
ls: cannot access '/c/Users/akhilesh/.ssh': No such file or directory

Generating a new SSH key and adding it to the ssh-agent

akhilesh@AKHILESHPC MINGW64 /

$ ssh-keygen -t rsa -b 4096 -C "akhilesh@yourOrganisation.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/akhilesh/.ssh/id_rsa):
Created directory '/c/Users/akhilesh/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/akhilesh/.ssh/id_rsa.
Your public key has been saved in /c/Users/akhilesh/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:GENERATED RSA XXXXXXXXX20@yourOrganisation.com
The key's randomart image is:
+---[RSA 4096]----+
| .   ==          |
|. o +.+.         |
|.o * * +.        |
| .+ + *.o..      |
|.+   . oSo .     |
|+ O    B..o      |
|.B =  =.+.       |
|. + .+o.E        |
|   oo..o         |
+----[SHA256]-----+


Adding your SSH key to the SSH-agent:

akhilesh@AKHILESHPC MINGW64 /
$ eval "$(ssh-agent -s)"

Agent pid 10140
akhilesh@AKHILESHPC MINGW64 /
$


To add a new SSH key to your GitHub account, copy the SSH key to your clipboard.

$ clip < ~/.ssh/id_rsa.pub


Go to: https://help.github.com/articles/adding-a-new-ssh-key-to-your-github-account/  and follow the steps to add SSH to your GitHub account.

Creating an access token

Go to https://GitHub.yourOrganisation.com/settings/tokens. Follow the step given at: https://help.GitHub.com/articles/creating-an-access-token-for-command-line-use/ That token now effectively becomes your password when asked.

Clone GitHub source code

akhilesh@AKHILESHPC MINGW64 /d/yourproject-api09Jun
$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
# exp : git clone https://GitHub.yourOrganisation.com/akhilesh/yourproject-api.git
Cloning into 'yourproject-api'...
Username for 'https://GitHub.yourOrganisation.com': akhilesh
#Promt window for Password : PASTE YOUR TOKEN HERE
remote: Counting objects: 3824, done.
remote: Compressing objects: 100% (1889/1889), done.
remote: Total 3824 (delta 1899), reused 3824 (delta 1899), pack-reused 0
Receiving objects: 100% (3824/3824), 4.19 MiB | 193.00 KiB/s, done.
Resolving deltas: 100% (1899/1899), done.
Checking connectivity... done.
Checking out files: 100% (7164/7164), done.  


Checking out the specific branch

Clone creates the master branch. However, you will have to tell it the specific branch that you want to check out.

akhilesh@AKHILESHPC MINGW64 /d/yourproject-akhilesh
$ cd yourproject
akhilesh@AKHILESHPC MINGW64 /d/yourproject-akhilesh/your project (master)
$ git checkout sprint7
Branch sprint7 set up to track remote branch sprint7 from origin.
Switched to a new branch 'sprint7'
akhilesh@AKHILESHPC MINGW64 /d/yourproject-akhilesh/your project  (sprint7)

$


Pushing to a remote

Use git push to push commits made on your local branch to a remote repository.

$ git push  <REMOTENAME> <BRANCHNAME>


Fetch

Use git fetch to retrieve new work done by other people.

$ git fetch remotename


Merge

Merging combines your local changes with changes made by others.

$ git merge remotename/branchname


Pull

Git pull is a convenient shortcut for completing both git fetch and git merge in the same command:

$ git pull remotename branchname


For more details go to https://help.github.com/

The Integration Zone is brought to you in partnership with CA Technologies.  Use CA Live API Creator to quickly create complete application backends, with secure APIs and robust application logic, in an easy to use interface.

Topics:
github enterprise

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

SEE AN EXAMPLE
Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.
Subscribe

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}