Since we are not allowed to use Visual Studio Code's Remote-SSH feature and the sftp extensions have limited functionality, I decided to leverage vsc's task system to create something very similar to Remote-SSH. Below is a brief description of what tasks.json and launch.json are doing to accomplish this goal. If you'd rather just get your environment set up:
These tasks (.vscode/tasks.json) work by copying local src files to the teaching server using rsync.
rsync -av ${workspaceFolder}/pintos/src thor:~/CSE130/Lab2/pintos/
triggering make via ssh
ssh thor 'cd ~/CSE130/Lab2/pintos/src/threads && make'
and then starting up GDB such that it will wait and listen for connections on port 1025.
ssh thor 'cd ~/CSE130/Lab2/pintos/src/threads && ~/CSE130/Lab2/pintos/src/utils/pintos --gdb --gdb-port=1025 -v -k -T 20 --qemu -- -q run ${input:test}
In order to connect though, we have to open an ssh tunnel. This is because we are trying to access a program running on the server from our local machine.
ssh -L 1025:localhost:1025 thor
This makes it so that localhost:1025 on our local machine is connected to port 1025 on
the remote server. Which
by design, is the port that GDB is listening on.
Now that we have a way to communicate to the server, the launch task can connect using
GDB as if we were running
everything on our own local machine.
In order to avoid having to enter passwords over and over again, all of the commands relying on ssh take advantage of sshpass. Sshpass essentially forwards a plain text password to any ssh command.
sshpass -p <password> ssh thor
nano ~/.ssh/config
scp -r thor:~/CSE130/Lab2 .
.vscode