skip to content
 

Digital Services

Community

An online discussion and research collaboration forum centred around our current academic events and popular research areas. To access Community, please register using one of the available social options and then complete the sign-up process. You'll then be added into the relevant groups to access the private discussion areas for your event(s). 

 

Sign in to Community

 

Codehive

A code collaboration and sharing platform for event participants. 

 

Sign in to Codehive

 

Configuring Codehive

Configuring SSH

SSH is a communication protocol which enables secure connections and data transfers between two hosts. It consists of a key pair - one half public, one half private. The public key part ends with the .pub file extension, whereas the private part does not. Never share the private key. To instruct git to push to Codehive, we'll add the public part to your Codehive account.

This guide has been collated and adapted from the GitHub (Checking for existing SSH keys, Generating a new SSH key and adding it to the ssh-agent) and GitLab and SSH keys.

 

Checking for exsting keys

  1. Open Terminal (Mac/Linux) or GitBash (Windows).

  2. Enter ls -al ~/.ssh to see if existing SSH keys are present:

    $ ls -al ~/.ssh
    # This lists the files in your .ssh directory, if they exist
  3. Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:

    • id_rsa.pub
    • id_ecdsa.pub
    • id_ed25519.pub

If you don't have an existing public and private key pair, or don't wish to use any that are available to connect to GitHub, then skip to the generate a new SSH key section.

If you see an existing public and private key pair listed (for example id_rsa.pub and id_rsa) that you would like to use to connect to Codehive, skip to the add your SSH key to the ssh-agent section.

 

Generate an SSH key pair

  1. Open Terminal (Mac/Linux) or GitBash (Windows).

  2. Paste the text below, substituting in the email address associated with your Codehive account.

    $ ssh-keygen -t rsa -b 4096 -C "your_email[at]example[dot]com"

    This creates a new ssh key, using the provided email as a label.

    > Generating public/private rsa key pair.
  3. When you're prompted to "Enter a file in which to save the key", press Enter. This accepts the default file location.

    Linux

    > Enter a file in which to save the key (/home/you/.ssh/id_rsa): [Press enter]

    Windows

    > Enter a file in which to save the key (/c/Users/you/.ssh/id_rsa):[Press enter]

    Mac

    > Enter a file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]
  4. At the prompt, type a secure passphrase. For more information, see "Working with SSH key passphrases".

    > Enter passphrase (empty for no passphrase): [Type a passphrase]
    > Enter same passphrase again: [Type passphrase again]

 

Adding the SSH key to the Agent

  1. Start the ssh-agent in the background.

    $ eval "$(ssh-agent -s)"
    > Agent pid 59566
  2. Add your SSH private key to the ssh-agent. If you created your key with a different name, or if you are adding an existing key that has a different name, replace id_rsa in the command with the name of your private key file.

    $ ssh-add ~/.ssh/id_rsa

These steps will need to be done each time your machine is rebooted. 

 

Adding your key to Codehive

  1. Copy your public SSH key to a location that saves information in text format. The following options saves information for ED25519 keys to the clipboard for the noted operating system:

    Mac

    pbcopy < ~/.ssh/id_ed25519.pub

    Linux (requires the xclip package)

    xclip -sel clip < ~/.ssh/id_ed25519.pub

    Git Bash on Windows

    cat ~/.ssh/id_ed25519.pub | clip

    If you’re using an RSA key, substitute accordingly.

  2. Navigate to http://www.codehive.newton.ac.uk and sign in.

  3. Select your avatar in the upper right corner, and click Settings

  4. In the left-hand sidebar, click SSH Keys.

  5. Paste the public key that you copied into the Key text box.

  6. Make sure your key includes a descriptive name in the Title text box, such as Work Laptop or Home Workstation.

  7. Include an (optional) expiry date for the key under “Expires at” section. (Introduced in GitLab 12.9.)

  8. Click the Add key button.

 

Pushing files to Codehive

Lines in blocks below are to be typed into a Terminal.

 

Git global setup

git config --global user.name "Your name"
git config --global user.email "Your email"

 

Create and push a new repository

git clone https://www.codehive.newton.ac.uk/staff/project_name.git
cd project_name
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master

 

Push an existing folder

cd local_existing_folder
git init
git remote add origin https://www.codehive.newton.ac.uk/staff/project_name.git
git add .
git commit -m "Initial commit"
git push -u origin master

 

Push an existing Git repository

cd existing_repo
git remote rename origin old-origin
git remote add origin https://www.codehive.newton.ac.uk/staff/project_name.git
git push -u origin --all
git push -u origin master

 

University of Cambridge Research Councils UK
    Clay Mathematics Institute London Mathematical Society NM Rothschild and Sons