Working Remotely

Regardless of whether you see yourself working in a career focused on systems programming, the skills you will learn working remotely with a Unix-based OS will be extremely useful later on. It is important to pick up basic command line skills, and you should also be comfortable making changes to files remotely using a text-based editor.

This page outlines some of the techniques you can use to make your life easier while working remotely. At a bare minimum, you should be able to log into your VM from your local development machine using an ssh alias by typing ssh VMNAME. If it isn’t easy to start working, then you’ll never get started.

Text Editors

The three most common terminal-based editors you’ll hear about are nano, vim, and emacs. It is strongly recommended that you learn the basics of at least one because you never know when they’ll come in handy. nano is the easiest: it has a helpful menu at the bottom to remind you of keybindings, uses the arrow keys to navigate, etc. However, it is not very powerful without quite a bit of customization.

vim (or at the very least, its ancestor vi) is installed almost everywhere and is very powerful. If you have time and are willing to learn something new, it is definitely worth a look.

emacs is a bit more user-friendly than vim but is still extremely powerful. However, you won’t find it installed installed as often because it has a massive amount of dependencies on other libraries, and is quite large. Install on your VM with sudo pacman -Sy emacs.

micro is a modern take on terminal-based text editing, supports the mouse and several of the usual keybindings you’ll find familiar (Ctrl+C to copy text, for instance). You can install it on your VM with:

curl | bash ; sudo mv ./micro /usr/local/bin

Finally, a note. While using a terminal-based text editor is not required in class, you should consider learning the basics over the course of the semester. Some students go all-in on vim, emacs, etc. and others stick to GUI-based editors on their local machine. Either way is fine. However, don’t let yourself get bogged down worrying so much about editors that you don’t actually work on the projects!

Passwordless ssh

You should be able to log into the USF CS machines without a password. If you haven’t already, set up passwordless ssh.

Setting up an ssh Alias

For general use, it’ll be easier to just ssh into your VM rather than using the serial console. You can set up your ssh configuration to do this. Edit ~/.ssh/config on your local machine, not the VM (create it if it doesn’t exist already) and add the following:

NOTE: The ServerAliveInterval 120 line sends a null packet every 120 seconds to keep your SSH connection alive. If you already have this in your configuration, no need to repeat it.

ServerAliveInterval 120

Host gojira

    hostname 192.168.122.VMID
    ProxyJump gojira

Note that you can leave entries from your other classes (if any) in the file. No need to remove anything, we’re just adding the lines above. Test out the connection by running ssh VMNAME on your local machine. Type in your VM user account’s password, and you should be logged in. To make our life even easier, we should copy over our ssh public key from our local machine:

[matthew@silicon ~]$ ssh-copy-id VMNAME
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/matthew/.ssh/"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
mmalensek@ password:

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'VMNAME'"
and check to make sure that only the key(s) you wanted were added.

Now I can log in instantly without my password!

ssh Tunneling

Your VM is buried inside the CS network, which unfortunately means you can’t just connect to it directly. However, once you have an ssh alias set up, you can easily forward connections from your local machine directly to the VM by creating an ssh tunnel.

Let’s assume you want to use Cyberduck to transfer files. You can forward the VM’s ssh port to your local machine with the following command:

[matthew@silicon ~]$ ssh VMNAME -L 2222:localhost:22 'echo Tunnel ready; cat'

You don’t actually need the last part ('echo ...; cat'), but this tells you that the tunnel is ready to go. Once you’ve done this, leave the terminal window running. Now, when configuring Cyberduck, you’ll enter localhost as the server and 2222 as the port. Cyberduck will think it’s connecting to your local development machine, but ssh is tunneling the connection through the network to your VM:

Cyberduck With Local Tunnel

There are several file transfer options available on macOS, Linux, and Windows. Once you have an ssh tunnel active, these programs simply connect to localhost:2222 and work as they usually would with any other remote server. The best part is that most of these programs allow you to sync edits between the remote server and your favorite text editor. For instance, you can “edit” the file through your file transfer program using Sublime Text, VS Code, etc.

Cyberduck is one option that works for Mac and Windows users, but can be a bit buggy at times. Here are some alternatives:

If you’re a Linux user, use your file manager to connect to a remote server and enter sftp://localhost:2222. Edit just like you would any other files/folders.

Windows Tunneling

Our recommendation is to stick with WSL so you can follow the Linux/Mac directions above. However, MobaXterm and Bitvise ssh client also allow you to set up tunnels with a GUI. MobaXterm also has an integrated file manager and terminal, so you can do all your development from one application.

If you’d like to use MobaXterm, you will need to set up three tunnels. Click the Tunneling icon and add the following:

Tunnel 1

Tunnel 2

Tunnel 3

VMUSERNAME is your CS login, and you’ll use your CS password for the ssh connections. Here’s a screenshot of my configuration (using ID number 282):

MobaXterm Tunneling

Make sure you start the tunnels before moving on.

Click the Session button in the MobaXterm toolbar, then choose SSH. Then enter:

We can also transfer files from MobaXterm. Click the Session button in the toolbar, then choose SFTP. The parameters will be the same as above (localhost, VMUSERNAME, 2223). Connect, and you should see the files on your VM.