Remote Development with VS Code on Mac in 5 simple steps

Christina Jacob
Mac O’Clock
Published in
4 min readAug 9, 2020

--

This is about using VS Code for remote development on mac os.

VSCODE

Why VSCode?

With COVID-19 pandemic spreading, as everyone else I had to work from home Since march. I started using tmux after a few months into my first job so that I will have the same session at home or office or anywhere I login to my machine. That was enough for me during the old normal! But working from home had its own challenges, among which flaky connection was the worst. I looked for options, found mosh. With mosh you will have your session maintained even if you have your internet cut off for a few seconds, unlike an ssh connection that would get lost when your internet connection is interrupted, even from a short while. That wasn’t enough, the connection is maintained but my continuity is lost. Then I tried the option of Remote development with VS Code, that gave me a local development feel while connected to a codebase in a remote machine. Even if the connection is lost for 15–20 seconds you don’t have an impact, it reconnects automatically(if configured to) when the network comes back.

System requirements

Local: Ssh client compatible with openssh. On macOS, it comes preinstalled.

Remote SSH host: A running ssh server on your remote Linux machine [I used CentOS Linux release]

Below command can be used to do the same

sudo yum install openssh-server && sudo systemctl start sshd.service && sudo systemctl enable sshd.service

Installation

  1. Download and install VS Code for mac
  • Go to URL https://code.visualstudio.com/download and click on the download button.
  • Extract the zip file generated using the below command on the command line. or double click on the zip file to extract the content.

tar -xvzf VSCode-darwin-stable.zip

  • Double click on the Visual Studio Code. app to launch VS Code.

Note: Drag it to the application folder to make it available on the launch pad. Make it available on the dock by right-clicking and choosing option keep in doc

Install vscode on mac

Configure

step 0: Install Visual Studio Code Remote Development Extension Pack.

Click on the extensions icon.

Search for remote development extension pack.

Click install

Step1: Try connecting to a remote host.

To verify that you can connect to the remote machine, where your actual code base is executed the command from the terminal replacing username with your username on the remote machine and host IP with the IP of the remote machine.

ssh username@hostip

Step 2: Configuring ssh In VS Code

In the command pallete(F1)select Remote-SSH: Add New SSH Host… and use the same user@hostname as in step 1

Select Remote-SSH: Connect to Host… from the Command Palette (F1). From the drop-down choose the already added host. Type in the password when prompted for it.

From https://code.visualstudio.com/docs/remote/ssh

Vs Code will automatically detect the type of the server, if not you will be asked to select the type manually.

From https://code.visualstudio.com/docs/remote/ssh

You can edit this in vscode settings (Code > Preferences > Settings)by updating remote.SSH.remotePlatform property

After a moment, VS Code will connect to the SSH server and set itself up. VS Code will keep you up-to-date using a progress notification and you can see a detailed log in the Remote - SSH output channel. You can check the status bar to check the remote host you are connected to

From https://code.visualstudio.com/docs/remote/ssh

Step 3: You can then open any folder or workspace using File > Open… or File > Open Workspace… on the remote machine.

From https://code.visualstudio.com/docs/remote/ssh
Configure VSCode remote on MACOS

Reference

--

--

Christina Jacob
Mac O’Clock

System developer at vmware #cprogramming #opensource #kernel