View on GitHub

Kenneth V.

Personal Website for CSE 15L

back to main page

Lab Report 1 - Week 2

Remote Server Connection Through SSH

Hello incoming 15L students (and myself)! Here’s my journey on the very first lab of this course.

Because this is the first lab, there’s going to be a ton of things to set-up before we do some magic.

 

Preinstallation

Before everything happens, let’s start off with getting a text editor to code. To be honest, it doesn’t really matter which type of text editor you have (Elipse, VSCode, Notepad++, etc.), but for this course, we will be using Visual Studio Code (aka VSCode…the most common coding text editor).

Image

 

Connecting to a Remote Server

This is where it gets real cool but may be quite confusing. We’re going to be remotely connecting to a server and accessing it as a different device (but only through a terminal). We’re going to be using SSH (Secure Shell Protocol). Think of it like accessing & remotely connecting to a server like cloud gaming.

Part 1 - Preinstallation

Image

Part 2 - Finding your course-specific account

Part 3 - Connecting to the Remote Server Computer

 

Run Commands on the Remote Computer

 

Moving Files over SSH with scp

Part 1 - Creating a file to transfer

  1. On your computer (not accessing the server computer), create a file called WhereAmI.java & then put this piece of code into the file:
     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. Save the file, then in your terminal, run the javac & java commands for that file (you can skip this if you don’t have java installed):

    javac WhereAmI.java

    java WhereAmI

    • Keep in mind what this file does! It should print your system’s properties or info about it.

Part 2 - Transfering the file

  1. Now that we have the file on your computer, let’s use the scp command to transfer the file to the server computer:

    scp WhereAmI.java username@ieng6.ucsd.edu:~/

    • It should prompt you to enter your password just like logging in with ssh, so enter your password.
  2. Once it has done its magic, log back into the ieng6 server computer using ssh like the usual, and use the ls command. You should see that the WhereAmI.java file is right in your home directory!
  3. You’re able to use the javac & java commands to run the file, as the server has java installed! Try running those two commands to see what you get.
    • You probably should get the properties of the server computer that you are accessing!

    Image

 

SSH Keys

Part 1 - Generating the SSH Key Pair

  1. On your client (your computer), run the ssh-keygen command in your terminal.
    • It should prompt afterwards (after generating):
        Generating public/private rsa key pair.
        Enter file in which to save the key (/Users/<username>/.ssh/id_rsa):
      
  2. Once it prompts to enter a file, enter:

    (/Users/<username>/.ssh/id_rsa): /Users/<username>/.ssh/id_rsa

  3. Once it prompts for a passphrase, don’t enter one. Just hit enter.
    • It’ll ask to enter the same passphrase again. Hit enter again.
  4. You’ll see that it has saved the identification and public key to a specific directory. Also you should see the key fingerprint & the key’s randomart image (pretty neat!).

    Image

Part 2 - Copying Public Key to Your Account on the Server

 

Optimizing Remote Running

Image

back to main page