SSH Based Communication with GitHub

June 1, 2021

Watch Week 2 Session on Youtube



Table of Contents































1. Staying Current with a Remote Repository

The official repository of Summer of Code 2021 is located at https://github.com/wyoibc/soc2021. Now that you have started following its contents, it makes sense to (1) have a copy of it on your computer, and (2) learn how to keep your copy current with what is upstream (i.e. on GitHub). If you were to copy this repository right now, you will have the most current version of it. But once I make any changes to the upstream, your copy will become slightly stale. In this section, we will learn how to make it current again.

1.1 Copying or Cloning a Repository

cd ~/Github

git clone https://github.com/wyoibc/soc2021


1.2 Keeping the Clone Current with Upstream

git pull



2. Secure Communication with GitHub


2.1 Generate SSH Key Pair

ssh-keygen -t rsa -b 4096 -C "name@host.edu"
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/wyoibc/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 

Your identification has been saved in /Users/wyoibc/.ssh/t_rex.
Your public key has been saved in /Users/wyoibc/.ssh/t_rex.pub.
The key fingerprint is:
SHA256:4ps5bMhN7293Grtr0v+dCsUI4Ji02WQL9v+Wut7uOu4 name@host.edu
The key's randomart image is:
+---[RSA 4096]----+
|     + +         |
|    o % o        |
|     = = .       |
|        . . o    |
|      . S. . o   |
|     ...  . o    |
|   . =..   *.    |
|    o =+..* =o. o|
|     .+o=EBB=Booo|
+----[SHA256]-----+


2.2 Associate Public Key with GitHub

cd /Users/wyoibc/.ssh/

pbcopy < t_rex.pub  







2.3 Configure Your System to Use SSH Keys

ssh-agent -s

ssh-add /Users/wyoibc/.ssh/t_rex
ssh-add -l

4096 SHA256:uMFoUIUC7osmgDQaNowsOnqEt3XmPPZe4RnR2+Q1KB0 name@host.edu (RSA)
cd /Users/wyoibc/.ssh

vim config
Host *
   AddKeysToAgent yes
   UseKeychain yes

Host wyoibc.github.com
        HostName github.com
        User git
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/t_rex
:wq


2.4 Test Your SSH Key

cd /Users/wyoibc/Dropbox/Github/testgit
df <- read.csv("us.csv", header=T)

plot(1:489, df$deaths, pch=16, col="salmon", cex=0.5, xlab="Days", ylab="Num. Deaths")
png("covid_combined.png", width=10, height=7, unit="in", res=600)

par(mfrow=c(1,2), mar=c(5,4,4,2), oma=c(2,2,2,2))

plot(1:489, df$cases, pch=16, col="darkgreen", cex=0.5, xlab="Days", ylab="Num. Cases")

plot(1:489, df$deaths, pch=16, col="salmon", cex=0.5, xlab="Days", ylab="Num. Deaths")

title(main="COVID-19 Cases and Deaths 2020-21", outer=TRUE, cex.main=0.9)

dev.off()
---
title: COVID-19 Cases & Deaths
author: Vikram Chhatre
date: June 1, 2021
---

1. The following plot shows number of COVID-19 cases and deaths in the United States from January 2020 through May 2021.


<center>
<img src="covid_combined.png" width=700>
</center>
git add .

git commit -m "Added a new plot"
cd /Users/wyoibc/Dropbox/Github/testgit/.git

vim config
url = git@github.com:wyoibc/testgit.git
git push




3. Collaborating on GitHub

3.1 Bears Generate New Repository and Initial Content



3.2 Foxes Clone Repository and Edit it

- Save this file as ``rnorm_100.png`` in the current folder.

- Now let's go back to ``README.md`` and update its contents as follows:

    ```bash
    ---
    title: Collaborative Exercise in Github
    ---


    ## QQ Normalization


    - Normalizatio using rnorm 100 sampling

    <center>
    <img src="qqnorm_100.png", width=500 />
    </center>
    ```

- Save and close the file. Then perform git operations as follows:

    ```bash
    git add .
    git commit -m "Edit by Foxes"
    git push origin master
    ```

- Verify that the contents were uploaded to your partner's Github repository (on which you are a collaborator).



3.3 Bears Pull Updates and Add to the Repo



- Finally, push the updates upstream with ``git add``, ``git commit`` and ``git push``



3.4 Foxes Pull Updates