View on GitHub

Kenneth V.

Personal Website for CSE 15L

back to main page

Lab Report 3 - Week 6

Continuous Integration & More Unix

Heyo! This is the third lab report for CSE 15L. This time around, we are now using the application of continuous integration with the addition of making our remote server access even more convenient.

Continous integration is the application to the consistent upload of some sort of program/software and then goes through an automated test to check whether or not the overall program/software will be good for release.

For the most part of this lab report, I am going to be focusing on accessing GitHub and our remote server more conveniently. Just think of it like you are in the carpool lane with no traffic compared to other normal lanes.

 

Streamlining ssh Configuration

Usually, when we log into the remote server (ieng6), we type something along the lines of :

ssh cs15lsp22###@ieng6.ucsd.edu

But the only thing that may be a hassle would be to remember your account (which even I don’t have it down), so it would be preferable to have some sort of shortcut instead of copy & pasting your account from somewhere.

The Solution

The easiest way to make this easier on ourselves is to make a key term that replaces our account. So, here’s how:

  1. Locate where you created your ssh-keys on your computer:

    ~/.ssh/config

    • Should be within the .ssh folder
  2. Make a config file that tells ssh what username & nickname to use to log in to specific servers in ~/.ssh/config.

Image

  1. Open the config file through any text editing program (in my case, VSCode), and copy & paste this into it…then save!

     Host ieng6
         HostName ieng6.ucsd.edu
         User cs15lsp22###
    
    • For your user, it’s just the front info before the @.

Now that we have the config file inside our .ssh folder, we can test if it worked or not through our terminal…and success!

Image

Testing it further, let’s try to use scp using our shortcut:

  1. We can copy any file, so in this case, I made a file called testing.txt

  2. Make sure you know where your file is located and then:

    scp testing.txt ieng6:~

    • In my case, I had to find the directory of where my text file was (ex. /randomfolder/testing.txt)

Image

GitHub Access via ieng6

Normally when we are in ieng6, we can clone, pull, and git status for our particular GitHub repository. Though we didn’t see much commit nor push through the command line.

Apprently, when you try to commit or push, you’ll likely run into this error:

Image Image

The Solution

To be honest, this took so much effort to figure out how to allow pushing and all of that of GitHub from ieng6. But here’s how I did it:

  1. Make a key for GitHub through key-gen command & place it into your .ssh folder Image
    • In my case, I named it id_rsa_github.
  2. Copy the content within your GitHub public key
    • You can use the terminal to copy it in, or open any text editor to open the file:

      id_rsa_github.pub

  3. Go back to GitHub, go to settings, then under the SSh and GPG keys, add your copy and paste your key there.

Image

  1. Additionally, I added this these lines into my .ssh config file:
    Host github.com
     HostName github.com
     User <insertusernamehere>
     IdentityFile ~/.ssh/id_rsa_github
    
    • NOTE: Your username is your github username.

Now that we technically have a key setup for GitHub Access, it is time to attempt to push commits from ieng6. Here are some things to recognize or to troubleshoot on:

  1. If you cloned your repository via HTTPS, you’re going to need to use this command to make it work for SSH:

    git remote set-url origin git@github.com:<\github_username>/<\repository_name>.git

  1. Double check that your public/private key pairs match in GitHub

  2. If all goes to fail, generate a personal access token that you can copy and paste as your password (your username remains the same though). Image

Besides that, you should be able to push your changes now!

Image

Image

Copy Whole Directories w/ scp -r

We often deal with directories filled with a ton of files. It could be that we have folders within folders or even more. So, we’re going to be using a single line to copy an entire directory and run it through ieng6.

In my case, I’m going to be making an entire copy of my MarkdownParse directory. This entire command is multiple commands in a single line:

scp -r . ieng6:~/markdown-parse-copy; ssh ieng6 "cd markdown-parse-copy; /software/CSE/oracle-java-17/jdk-17.0.1/bin/javac -cp .:lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar MarkdownParseTest.java; /software/CSE/oracle-java-17/jdk-17.0.1/bin/java -cp .:lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore MarkdownParseTest"

Before doing it in a single line, we need to recognize what we are doing step by step:

  1. Using scp to copy entire directory to ieng6 server

    scp -r . ieng6:~/markdown-parse-copy

    • The markdown-parse-copy at the end of the this command can be any file name.
    • This also combines our streamline ssh short key ieng6
    • Make sure in your command line directory, that you are INSIDE THE DIRECTORY YOU WANT TO COPY
      • ex. ...\GitHub\markdown-parser> scp -r . ieng6...

    Image Image

  2. Log into ieng6 & going into the copied directory

    ssh ieng6 "cd markdown-parse-copy;...

    • Everything in quotes will be now continued in the ieng6 operating system (which I believe is linux)
    • The ... refers to the following commands below
  3. Compiling the tester

    .../software/CSE/oracle-java-17/jdk-17.0.1/bin/javac -cp .:lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar MarkdownParseTest.java;...

  4. Running the tester

    .../software/CSE/oracle-java-17/jdk-17.0.1/bin/java -cp .:lib/junit-4.13.2.jar:lib/hamcrest-core-1.3.jar org.junit.runner.JUnitCore MarkdownParseTest"

Image

Result

Here are the results when we run this single line:

back to main page