Access a Private GitHub Repository Remotely (2024)


Logins have changed for users with accounts on submit1 and submit2: please see the

login guide

for details on your new login information.

This guide describes how to remotely access a private GitHub repository from the HTC and HPC clusters, specifically

You will need to have access to a CHTC cluster. You will also need to have a GitHub account with access to the private repository of interest.

A. Generate the SSH Key Pair

We will be following the instructions provided by GitHub to generate the SSH key pair (Generating a new SSH key…).

  1. Log in to the submit node as usual (Connecting to CHTC).

  2. Generate the SSH key by running the following command, where the example email is replaced with the email that you use for your GitHub account.
    ssh-keygen -t ed25519 -C "your_email@example.com"

    A message will appear stating that the key pair is being generated.

  3. A second message will appear prompting you to enter the location where the SSH keys should be stored:
    Enter a file in which to save the key (/home/your_NetID/.ssh/ed25519):

    Simply hit the enter key to accept the specified file path.

    Note: If a SSH key already exists at the displayed path it will be overwritten by this action.This can be avoided by typing in an alternate path before pressing the enter key.

  4. You will be prompted to create a passphrase. Type your desired passphrase and then hit enter. Repeat a second time when asked to confirm your passphrase.

    Warning: If you leave the passphrase empty (hit enter without typing anything), a passphrase will not be created nor required for using the SSH connection. In principle, this means anyone with access to the private key can access and modify your GitHub account remotely.

  5. A message will appear confirming the creation of the SSH key pair, as well as the paths and names of the private and public keys that were generated. Make note of these paths for use in the following steps.

B. Add the SSH Key to Your GitHub Account

Now we will be adding the SSH public key to your GitHub account, following the instructions provided by GitHub (Adding a new SSH key to your GitHub account).

  1. Copy the contents of the public SSH key file (id_ed25519.pub) created in Part A. There are several ways of doing this.

    If you provided an alternate file name in Step 3. of Part A., then the public SSH key will be the name of that file plus the .pub extension.

    • Print the contents of the file to the screen by entering the following command, replacing your_NetID with your actual NetID.
       cat /home/your_NetID/.ssh/id_ed25519.pub
    • Use a terminal editor (nano, vi, etc.) to open and view the file
    • Use a file transfer method to transfer the file to your local computer (Transferring Files).
  2. Next, log in to github.com using the same email that you used in Step 2. of Part A.
  3. Go to your account settings by clicking on your profile icon in the top right corner of the webpage, then click on Settings within the drop-down menu. If your browser window is small, the Settings button can be found by clicking the menu button at the top left of the webpage.
  4. Go to the SSH and GPG keys section. Under the SSH keys section, click New SSH key.
  5. Paste the contents of the SSH public key from Step 1. into the Key textbox.
  6. Name the SSH key using the Title textbox. We recommend “CHTC” plus the name of the login node. For example: “CHTC ap2001”.
  7. Click Add SSH key. The SSH key will now appear in the SSH keys section in your GitHub account settings.

C. Accessing Your Private GitHub Repository from the Cluster

Once the SSH key has been added to your GitHub account, you can access your private repository using the repository’s SSH address.

  1. In your web browser and while logged in to your GitHub account, go to webpage for the private repository.
  2. Click the <>Code button, then select the Local tab and then the SSH tab.
  3. Copy the SSH address that is shown.
  4. On the CHTC submit node, you can now access the repository using git commands by using the SSH address in place of the HTTPS address. For example,

    git clone git@github.com:username/user-private-repository.git
  5. If prompted for a passphrase when running commands with the SSH address, provide the passphrase you created in Step 4. of Part A.

From an interactive job

Because the interactive job takes place on a different node than the submit node, it will not know about the SSH key that you set up above. Use the following instructions to transfer and use the private identity key in the interactive job (see Compiling or Testing Code with an Interactive Job for more information on interactive jobs).

  1. When creating the submit file for your interactive job, include the path to the private SSH key identity file as a value for the transfer_input_files keyword. This will ensure that the identity file is copied to the interactive job directory. For example,

    transfer_input_files = /home/your_NetID/.ssh/id_ed25519, /path/to/include/other/files

    Note: Make sure that you are transferring the private SSH key file, not the public. The public SSH key should have the .pub extension, while the private SSH key does not.

  2. Once your submit file is set up, start the interactive job using condor_submit -i and then the name of your submit file. When the interactive job has started, you will see that the private SSH key file is included in the initial directory. The SSH program, however, still needs to be told to use it.
  3. Initialize an SSH agent using the command

    eval "$(ssh-agent -s)"
  4. Add the private SSH to the SSH agent by using the ssh-add command followed by the name of the private SSH key file that you transferred. You will be prompted to enter the passphrase that you created when you created the SSH key pair. For example,

    ssh-add id_ed25519

    You will now be able to access the repository during the interactive job.

Additional Notes

  • If you forget the passphrase you created in Step 4. of Part A., you will need to repeat this guide to create a new SSH key pair to replace the previous one.
  • When using the SSH address to your repository with non-git commands, you may need to replace the colon (:) in the address with a forward slash (/). For example,

    Original SSH address

     git@github.com:username/user-private-repository.git

    Modified SSH address

     git@github.com/username/user-private-repository.git
Access a Private GitHub Repository Remotely (2024)

FAQs

Can you access a private GitHub repository? ›

Private repositories are only accessible to you, people you explicitly share access with, and, for organization repositories, certain organization members.

How can I see who has access to a private GitHub repository? ›

Filtering the list of teams and people
  1. On GitHub.com, navigate to the main page of the repository.
  2. Under your repository name, click Settings. ...
  3. In the "Access" section of the sidebar, click Collaborators & teams.
  4. Under "Manage access", in the search field, start typing the name of the team or person you'd like to find.

Could not read from remote repository please make sure you have the correct access rights GitHub? ›

Verify your SSH key setup: Make sure that your SSH key is properly set up and registered with your GitHub account. You can follow the instructions on GitHub's documentation to generate and add an SSH key. Check your SSH agent: Ensure that your SSH agent is running and that your key is added to the agent.

Is it possible to share a private GitHub repository? ›

About collaboration in a personal repository

To collaborate with users in a repository that belongs to your personal account on GitHub, you can invite the users as collaborators. If you want to grant more granular access to the repository, you can create a repository within an organization.

Can people see my private GitHub? ›

About private profiles

To hide parts of your profile page, you can make your profile private. This also hides your activity in various social features on GitHub. A private profile hides information from all users, and there is currently no option to allow specified users to see your activity.

Do private repositories show up on GitHub? ›

Your contribution graph and Achievements show activity from public repositories. You can choose to show activity from both public and private repositories, with specific details of your activity in private repositories anonymized.

Can anyone clone a private repository? ›

Cloning a private repository can be a little bit tricky and is only possible if these conditions are met: The cloner is cloning from a personal account. The repository is from an organization of which the cloner is a member.

Can a private GitHub repo be made public? ›

Changing a repository's visibility

Under your repository name, click Settings. If you cannot see the "Settings" tab, select the dropdown menu, then click Settings. In the "Danger Zone" section, to the right of to "Change repository visibility", click Change visibility. Select a visibility.

Can you see if someone viewed your GitHub repository? ›

If your project is hosted on GitHub, you can view how many people land on your project and where they come from. From your project's page, click “Insights”, then “Traffic”. On this page, you can see: Total page views: Tells you how many times your project was viewed.

Are private repository names visible? ›

A private repository is visible only to users who have permission to see it. A public repository is visible to everyone.

How do I see who is watching my GitHub repository? ›

Under your repository name, click Insights. At the bottom of the left sidebar, click People. Above the list of people, click Export CSV.

How to access git repository remotely? ›

SSH URLs provide access to a Git repository via SSH, a secure protocol. To use these URLs, you must generate an SSH keypair on your computer and add the public key to your account on GitHub.com. For more information, see "Connecting to GitHub with SSH."

How do I see access rights to my GitHub repository? ›

To check if you have admin rights on your repository in GitHub, follow these steps:
  1. Login to GitHub: Make sure you are logged into your GitHub account.
  2. Navigate to Repository: ...
  3. Repository Settings: ...
  4. Options on the Left Sidebar: ...
  5. Manage Access: ...
  6. Permissions:
Aug 20, 2023

How do I authenticate my GitHub remote? ›

If you're not a member of an enterprise with managed users, you will authenticate using your GitHub.com username and password, or a passkey. You may also use two-factor authentication and SAML single sign-on, which can be required by organization and enterprise owners.

Do GitHub Pages repositories have to be public? ›

Warning: GitHub Pages sites are publicly available on the internet, even if the repository for the site is private. If you have sensitive data in your site's repository, you may want to remove the data before publishing. For more information, see "About repositories."

Can a private repo have GitHub Pages? ›

GitHub Pages is available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see "GitHub's plans."

Top Articles
Latest Posts
Article information

Author: Melvina Ondricka

Last Updated:

Views: 6658

Rating: 4.8 / 5 (48 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Melvina Ondricka

Birthday: 2000-12-23

Address: Suite 382 139 Shaniqua Locks, Paulaborough, UT 90498

Phone: +636383657021

Job: Dynamic Government Specialist

Hobby: Kite flying, Watching movies, Knitting, Model building, Reading, Wood carving, Paintball

Introduction: My name is Melvina Ondricka, I am a helpful, fancy, friendly, innocent, outstanding, courageous, thoughtful person who loves writing and wants to share my knowledge and understanding with you.