CS 70

Connecting to the CS 70 Server

C++ works slightly differently on every computer system; even slight changes in versions of the standard library, for example, can lead to big differences in observable behavior.

To make sure that the behavior you see matches what we see when we test your code, you'll be running your code on a remote server. The CS 70 server will have all of the libraries and tools you'll need to complete your assignments this semester.

Set Up Your CS 70 Server Account

We have created an account for you, username, on the CS 70 server (cs70.cs.hmc.edu), but there are a few things you'll need to do to get things set up.

Pick a New Password

When you log in for the first time, you'll be prompted to change your password. Take a moment right now to choose a strong password that you haven't used before and that you'll be able to remember. (If you have a password manager on your phone, it may be able to help you with creating a strong password and storing it securely in case you forget.)

  • Goat speaking

    How about goat42?

  • LHS Cow speaking

    No. It's really important that you pick a secure password. Bad actors constantly scan all computers connected to the internet (including cs70.cs.hmc.edu) and try to log in with hundreds or thousands of plausible usernames and passwords. If you pick a weak password then there's a high probability your account will be compromised.

  • Rabbit speaking

    And once hackers have a toehold on a machine, they can use that to scan the inside of the network and potentially access other machines as well, or exploit other vulnerabilities.

Log in for the First Time

The first time you log in, you'll use a temporary password that you'll be asked to change. You can click the button below to reveal your temporary password (every student has a unique temporary password, the one below is yours).

Open a terminal to get a command-line prompt (on your computer, or inside Visual Studio Code) and connect to cs70.cs.hmc.edu with the command

ssh username@cs70.cs.hmc.edu

where username needs to be your actual username on the server (e.g., first initial + last name).

When you log in, it will ask for your old password (i.e., the temporary password above, for a second time) and then ask you to pick a new password. Once you've changed your password successfully, the ssh connection will end. You can then try sshing in again using your new password, as described in the next section.

  • Hedgehog speaking

    Help! I'm confused!

  • LHS Cow speaking

    No worries; this will be new to many of you. Check out this video where Prof. Bang does the same thing, though he's using cs131.fun and we are using cs70.cs.hmc.edu.

  • RHS Cow speaking

    If that doesn't get you going, please ask for help!

Log in and Configure Git

Run the same ssh command (i.e., ssh username@cs70.cs.hmc.edu) and log in with your new password. You should see a big “CS 70” banner and get a prompt (e.g., ~ SERVER >) which shows that you are currently in your personal home directory (a.k.a. ~ or /home/username) and waits for you to type a command to run.

Try these commands:

hostname
Should say that the machine where this command ran is cs70-server.
pwd
Should say that you are currently in your personal directory /home/username
ls
Should show you the contents of your home directory, including the subdirectories data and cs70.

While you are logged in, run the following two commands to configure git:

git config --global user.name "your-name"
git config --global user.email "your-email@example.com"

where you put your own name and email address in the quotes.

  • LHS Cow speaking

    If you don't get an error message, everything worked!

  • Dog speaking

    Hooray!

Finally, you can end your remote session on the CS 70 server by running the command exit.

Log Into the Server Using VS Code

At this point we will switch to using Microsoft's Visual Studio Code editor to connect to the server instead of using the ssh command directly. VS Code will let you transparently work on files on the server without having to copy files back and forth from a terminal.

  • Rabbit speaking

    VS Code actually uses ssh behind the scenes!

Open the VS Code app on your computer (or a CS Lab computer). The first window that opens allows you to edit files on the hard drive of the computer you are using.

Click on the >< button in the lower-left corner. In the pop-up menu, select Remote-SSH: Connect to Host... and enter username@cs70.cs.hmc.edu for the host (where username is replaced by your CS 70 server username). When prompted, enter the password you set above.

A new “remote” window will pop up! This window is essentially running on the remote computer cs70.cs.hmc.edu, so you can edit files stored on the server machine and run commands on the server.

  • LHS Cow speaking

    VS Code might be a little bit slow at first as it initializes the remote connection. (It has to download a copy of itself to the server.)

  • RHS Cow speaking

    Connecting should be smoother once that's done!

  • Hedgehog speaking

    I need help again!

  • LHS Cow speaking

    Sure thing. See if this video showing Prof. Bang connecting to the server with VS Code helps. (Although he's using cs131.fun instead of cs70.cs.hmc.edu, the basics are the same.)

Once you have the remote window, you can go ahead and close the other (local) window, as you won't need it.

Check that VS Code is Connected to the Server

Use the Control key instead of Command if you're not on a Mac. (The Control key should also work on a Mac, but using Command is more macOS-like.)

Using the View > Terminal menu option, or the Command ` keyboard shortcut, open a terminal to get a command-line prompt inside VS Code. (The terminal pane will typically pop up at the bottom of your window.)

Run the command hostname and verify that the terminal is running on the server. (If it tells you you're on a machine that isn't the server, you're probably not in the remote window.)

To Complete This Part of the Assignment...

You'll know you're done with this part of the assignment when you've done all of the following:

(When logged in, completion status appears here.)