Link Search Menu Expand Document

Editing code in your VM

Table of contents

  1. Using the SMB server
    1. Windows
    2. macOS
    3. Linux
  2. Using VSCode’s remote SSH feature
    1. Instructions for VirtualBox setup
    2. Instructions for M1 Mac setup

The VM contains a SMB server that lets you edit files in the vagrant user’s home directory. With the SMB server, you can edit code using text editors on your host and run git commands from inside the VM. This is the recommended way of working on code for this course.

Alternatively, if you use VSCode, you can use its remote ssh feature to connect to your VM quite easily. This process is detailed below.

These are two suggested ways to edit code in your VM, but you are free to do whatever suits you best. Another possibility is just using a non-graphical text editor in an SSH session.

Using the SMB server

Windows

  1. Open the file browser, and press Ctrl L to focus on the location bar.

  2. Type in \\192.168.162.162\vagrant and press Enter.

  3. The username is vagrant and the password is vagrant.

You should now be able to see the contents of the vagrant user’s home directory.

macOS

  1. Open Finder.

  2. In the menu bar, select Go → Connect to Server….

  3. The server address is smb://192.168.162.162/vagrant if using VirtualBox and smb://127.0.0.1:12445/vagrant if using the M1 setup.

  4. The username is vagrant and the password is vagrant.

You should now be able to see the contents of the vagrant user’s home directory.

Linux

Use any SMB client to connect to the /vagrant share on 192.168.162.162 with the username vagrant and password vagrant. Your distribution’s file browser probably has support for SMB out of the box, so look online for instructions about how to use it.

Using VSCode’s remote SSH feature

Instructions for VirtualBox setup

Follow these instructions if you chose VirtualBox setup. These instructions are for macOS, but the process should be very similar for other OSes.

  1. Change into the directory of your vm: cd cs162-vm.

  2. Make sure the machine is up and running: vagrant up.

  3. Append the machine’s ssh config to your system’s SSH config: vagrant ssh-config >> ~/.ssh/config.

  4. Follow instructions 1 - 3 in Editing code on the instructional machines and during step 3, after clicking “Remote-SSH: Connect to Host”, click on the option labeled “default”.

Instructions for M1 Mac setup

Follow these instructions if you chose M1 Mac setup.

  1. Follow the steps in Editing code on the instructional machines but for step 4, replace the ssh command with ssh -p 16222 vagrant@localhost. You can skip step 6.