Connecting to a remote machine in vs code
With the remote plugin installed, we can now connect to a remote machine. I
mostly do this using ssh
. Make sure you first have ssh keys copied to the
device you want to link to. Then, open the command pallet (CMD/CTRL-Shift-P
), and search for the Remote-SSH: Connect to Host...
command, and run it.
This will prompt you for an ssh host to connect to. Just enter a host
like
you would when using ssh
. For example, ryan@example.com
. If it’s the
first time adding a host, the plugin will ask where it can save a config file
for the hosts. I usually just select one of the defaults it offers me.
The connected status is displayed in the lower left of the window (top window: remote, bottom: local)
When connecting to a remote machine, VS code will usually pop open a new
window. To verify, the ip address of the machine that the window is connected
to can be found in lower left corner.
Working on Projects, Remotely
Opening a directory in the remote window
When working in a remote VS Code window, everything is passed on from the
remote machine, as if you were sitting down at that computer. When opening a
new file or folder, you browse the contents of the remote filesystem, not
the local one.
Even the built in terminal runs on the remote machine. I still work in
tmux
, so I have my vscode terminal attach whatever tmux
session I need.
This provides me with the flexibility to switch to a new machine and pickup
where I left off. Using this setup, I get a full graphical IDE window, while
still reaping the benefits of vim
+ tmux
.
Working on this post, with `vim` opened in `tmux` in the built-in terminal
And yes… you can run vim
, inside tmux
, in the built-in VScode
terminal, in a VScode remote window. This is something I actually do quite
often XD.
Conclusion
I am almost always working from a different machine than the one which my
files and work are on. This setup has been idea for how I work. It is easy to
use, yet very powerful.
Sitting in front a gruvbox-themed VSCode window, connected to my desktop, and
typing using vim keybindings (via a vim plugin) has become my new default, no
matter what computer (or VM) I am physically working from. I love it.
Next Post:
Prev Post:
Setting up NFS
Jenkins Parallel Stashing