cse15l-lab-reports

Week 1 Lab Report

Hamza Dehaini


Installing VScode

  1. Go to the VSCode
  2. Follow the instructions in the website to download and install the application based on your OS System (Windows or MAC OS)
  3. After you are done installing VSCode, open the program, and you should come to a get started page similar to this:

Image


Remotely Connecting

  1. You will need to install the SSH client if you don’t already have it
    • For Windows users, to double check that you have the SSH client installed, you can open powershell on your machine and enter:
      Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
      
    • If you have it installed, you will get an output of:

Image

  1. To connect to the remote computer, you will need to open the VSCode terminal
    • Typing Ctrl or Command `
    • Or select Terminal -> New Terminal on the top of your VSCode menu bar
  2. Enter the SSH command in the VSCode terminal:
    ssh cs15lfa22zz@ieng6.ucsd.edu
    
    • replace cs15lfa22zz with your username from your course
  3. Select yes to the following prompt:
    The authenticity of host 'ieng6.ucsd.edu (128.54.70.227)' can't be established.
    RSA key fingerprint is SHA256:ksruYwhnYH+sySHnHAtLUHngrPEyZTDl/1x99wUQcec.
    Are you sure you want to continue connecting (yes/no/[fingerprint])?
    
  4. Type in your password. WARNING: There is no visual output when you are typing your password. Continue to type and enter your password and it is still being inputed, even if you can’t see it.
  5. It will then output and prompt of security warnings as you are now controlling the remote computer

Image


Trying Some Commands

Image

  1. Logout by either pressing Ctrl-D, or running the command exit in the terminal
  2. Run a few of the commands from step 1. Notice how the same commands are different. This is because you are looking at the files of your home computer, rather than the remote computer in step 1:

Image


Moving Files with SCP

  1. To copy and paste files between computers using SCP, we will use a test file for this task. Add a file to your computer titled WhereAmI.java with this code:
    class WhereAmI {
      public static void main(String[] args) {
     System.out.println(System.getProperty("os.name"));
     System.out.println(System.getProperty("user.name"));
     System.out.println(System.getProperty("user.home"));
     System.out.println(System.getProperty("user.dir"));
      }
    }
    
  2. Run these two commands in the terminal
    • This will make a class of WhereAmI.java, then run it. It should then output your OS, user, home, and directory name
      javac WhereAmI.java
      java WhereAmI
      
  3. Run this command to copy and paste the files from the client machine to the remote machine (Swich out ‘cs15lfa22zz’ woth your username and retype your password)
    scp WhereAmI.java cs15lfa22zz@ieng6.ucsd.edu:~/
    
    • This image displays the steps from 2 - 3

Image

  1. Log back in with the ssh command again
  2. Enter ls to the terminal to see all files in the current directory
  3. Type in these two commands for the same opperation once again. Notice OS, user, home, and directory name is different since it is a different computer altogether
    javac WhereAmI.java
    java WhereAmI
    
    • This image displays the steps from 2 - 3

Image


Setting an SSH Key

  1. To eliminate the need to continuously put in your password to swich computers and to copy files, we will use SSH keys
  2. Enter ssh-keygen to the terminal, and press enter not add any passphrase. You will know it finished when there is a randomart image at the end
    • This make a public and private key that saves to your client machine

Image

  1. Now, we need to copy the public key to the .ssh directory on the server
  2. Enter this line with your information:
    ssh cs15lfa22zz@ieng6.ucsd.edu
    
  3. On the server computer, enter this line, then logout:
    mkdir .ssh
    
  4. Back on your your client computer, enter this line with your information
    scp /Users/joe/.ssh/id_rsa.pub cs15lfa22@ieng6.ucsd.edu:~/.ssh/authorized_keys
    

    Image


Optimizing Remote Running

ssh cs15lfa22@ieng6.ucsd.edu "ls"
cp WhereAmI.java OtherMain.java; javac OtherMain.java; java WhereAmI

Image


Congrats! You’re now an expert in SSH and SCP :)