Editing code in your VM
Table of contents
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
Open the file browser, and press
Ctrl L
to focus on the location bar.Type in
\\192.168.162.162\vagrant
and press Enter.The username is
vagrant
and the password isvagrant
.
You should now be able to see the contents of the vagrant user’s home directory.
macOS
Open Finder.
In the menu bar, select Go → Connect to Server….
The server address is
smb://192.168.162.162/vagrant
if using VirtualBox andsmb://127.0.0.1:12445/vagrant
if using the M1 setup.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.
Change into the directory of your vm:
cd cs162-vm
.Make sure the machine is up and running:
vagrant up
.Append the machine’s ssh config to your system’s SSH config:
vagrant ssh-config >> ~/.ssh/config
.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 QEMU setup
Follow these instructions if you chose QEMU setup.
- Follow the steps in Editing code on the instructional machines but for step 4, replace the
ssh
command withssh -p 16222 vagrant@localhost
. You can skip step 6.