buy
Guide to Git – Set Up Access to Private Repositories

Overview

This document describes how to set up SSH access so you can clone a local Webuzo repository to a remote private repository. You must generate and copy SSH keys to the remote repository server before you can clone a local repository to the remote server.

This tutorial uses GitHub as an example host for a private repository. However, most of the steps in this tutorial are similar to the steps for any other private repository host.

Set up SSH access to private repositories

To set up access to private repositories, follow these steps

  • Open Terminal

Click on Terminal from End User Panel > Server Utilities > Terminal.
If Terminal option is not there then you need request Webuzo Admin to allow Shell access.
Once you’ve successfully connected to the terminal, continue following this guide.

  • Generate SSH key

Run the following command to create a SSH key :

ssh-keygen -t rsa -f ~/.ssh/repo -b 4096 -C "username@example.com"

Note : Replace repo with the name of the remote repository, username with your Webuzo username, and example.com with your Webuzo domain name.

For example, if your repository name is testrepo, your Webuzo username is soft, and your Webuzo domain name is webuzotest.com   then command should be :

ssh-keygen -t rsa -f ~/.ssh/testrepo -b 4096 -C "soft@webuzotest.com"

This command contains several parts. If you change anything in the command it can affect the performance of SSH key.

1) The -t flag indicates the type of algorithm for your SSH key.
2) The -f flag indicates the name for your public and private keys. With the -f flag, there is no need to specify the public key name as it will always be the same name as the private key, but with .pub as the suffix.
3) The -b flag indicates the size of the SSH key in bits.
4) The -C flag indicates a comment to add to your public key. This is helpful when identifying which public keys you have authorized in a remote system

Once you run this command, the system will prompt you to enter a passphrase so you do not enter a passphrase, and press Enter to continue.

  • Open SSH Access wizard

From End User panel navigate to Security > SSH Access.

Here you will see the key generated from terminal. Please refer following image.


From this wizard you need to Authorize  the key first.
After that copy the .pub key to add in Remote Host like GitHub.

  • Create the SSH Configuration File

To create the SSH configuration file, follow these steps:

  • Create the SSH configuration file if it does not exist:

touch ~/.ssh/config

  • Set the permissions of the ~/.ssh/config file to 0600:

chmod 0600 ~/.ssh/config

  • Set the owner and group of the ~/.ssh/config file:

chown webuzousername:webuzousername ~/.ssh/config

  • Open SSH Configuration File:
    Use any text editor to open the ~/.ssh/config file. This file holds SSH settings.

  • Inside the file, add these lines. Replace testing with your repository name.

Host testing
    Hostname github.com
    IdentityFile ~/.ssh/testrepo

  • This configuration allows SSH to use the specified private key (testrepo ) when connecting to the testing repository on GitHub.

  • Save the file.

  • Register SSH key with Host of your private repository

For example you are using GitHub, Please perform following steps :

1. Log in to your GitHub account.
2. Navigate to your private repository.
3. In the top right corner of the page, click Settings. A new page will appear.
4. In the left side click on Deploy keys menu. A new page will appear.
5. In the top right corner of the page, click Add deploy key.
6. In the Title text box, enter a custome name for the key.
7. In the Key text box, please paste the public SSH key from SSH Access page that you have created in previous step.
8. If you want to push code from Webuzo account to GitHub account you can select Allow write access checkbox.
9. Click Add Key

Once you successfully added the key in GitHub account you can directly use the Git TM Version Control feature to clone the same Private repository from GitHub.

  • Follow these setps to clone the same Private repository from  Git TM Version Control feature

Make sure to include ssh:// protocol at the beginning of the URL, like in the image.
And below where we used git@testing:

ssh://git@testing:gitHubaccount/demo.git

The testing here corresponds to the Host entry we defined in the SSH configuration file earlier. This setup allows SSH to use the specified configuration when connecting to the testing repository.

image


    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list