 Today we're going to use VS Code on our Windows machine for remote SSH development. For this video I assume you have another machine to connect to or a virtual machine. We're going to use the virtual machine I set up earlier in my How to Create a Linux Virtual Machine for Windows video. However, you can use whatever machine you'd like as long as you can access it. First we're going to install Git on our Windows machine so we have some basic tools outside of our remote machine. Open your web browser and search for Git download. It should be the first link. Go there and click download for Windows. Download the 64-bit Git for Windows setup and open it whenever it's done. For the install we're going to hit next for pretty much every option and keep the default. Next components. Next folder. Next editor. Next initial branch. Next path. Next SSH. Next HTTPS. Next line ending. Next terminal emulator. Next pull behavior. Next credential helper. Next extras. Next experimental options. And finally install. After it's installed uncheck view release notes. Check launch Git bash and click finish. Now we're going to create our SSH key. You'll use your SSH key for encryption and authentication whenever you connect to machines. An SSH key comes in two parts. A public key and a private key. You can share your public key. It lets others verify that anything you encrypt was encrypted by you and only you. Your private key is something you should never ever share. You use your private key to encrypt any data you send. It should be as important as a password. Keep it safe. You can protect your private key with a passphrase. Another word for password. So even if someone has your private key file they can't use it without a passphrase. We'll create our SSH keys now. I'll include all the commands I use in the description to save you some typing. To create our SSH keys type SSH dash key gen space dash t space ed25519. It'll ask where you want to save the private key. The default is good. So press enter. Now you can and should use a passphrase. We'll use a blank one for the purpose of this video. That's it. Now you have a private and public key. You can see the files in the dot SSH folder in your user folder. The private key doesn't have an extension and the public key ends with dot pub. We're going to use this SSH key to connect remotely to our virtual machine. This also works for other servers. First let's connect to our VM using our user password. Type SSH space then your username at symbol then the server. For me it'll be john at VM. Enter your user password of the machine and you should be connected without using your SSH key. You may have to confirm it's the correct server before typing your password by typing yes then enter. For the next step we'll need to get your virtual machine's IP address. If you're using Windows there's just some odd issues I encountered where I couldn't just use the name VM. To get the IP address of the virtual machine we're connected to type ip space-br space-4 space-addr. It'll be the line starting with eth and it's the four numbers separate by dots. In this case it's 172.25.196.48. To make your life easier select it right click and copy. Now hold control and press D to disconnect from the virtual machine. We're going to copy our SSH public key to the virtual machine so we can use it to authenticate instead of our password. Type ssh-copy-id space your username at IP address. Again in this case it's john at and I'll paste the IP address I copied earlier. If you get asked to confirm the server type yes and press enter. Now type your user password and press enter. It should say successfully copied your key to the server. This just means your public key got copied to the server not your private key. So you can freely copy your public key to other machines or services. For example services like github or gitlab use ssh keys as well. We're going to copy our private and public keys to our virtual machine since it's ours and we trust it. The virtual machine is going to connect directly to other servers so we'll just make our lives easier. Type scp tilde-dot ssh-id tab or id underscore ed25519 space tilde dash slash dot ssh slash id tab dot pub space user at server colon tilde slash dot ssh slash. Everything we need is on the virtual machine so we're going to connect to it again and get our source code set up on it. Connect back to the virtual machine by typing ssh space user at server and hit enter. If you're using github you need to copy the public ssh key there the dot pub file. I'll assume you've already added the public key to your github profile. In the screen capture you'll see me type the command in the wrong place. You should still be connected to your virtual machine. We'll copy a little hello world c repository I made by by typing git space clone space git at github.com colon alphson slash hello dash world dash c and hit enter. You may have to type yes and hit enter to connect to the server. Now we have our code on our virtual machine. If you encounter an error here about your ssh key type chmod space 600 space tilde slash dot ssh slash id tab or id underscore ed25519 you should be able to retype the git clone command again and it'll work. We're going to download visual studio code for our development environment. Search for vs code download and it should be the first link there. Download the x64 user installer for windows. Hopefully it's a quick download open it. Of course we'll accept the agreement without reading it and click next over and over again. Eventually we'll hit install and we'll have to wait. Leave launch visual studio code checked and click finish. After vs code launches the first thing we're going to do is install the remote ssh extension to connect to our virtual machine. Click file at the top go to preferences then extensions. Search for remote and remote dash ssh should be the first option. Click install beside the extension name after it's done installing we're ready to connect to our virtual machine. To connect to the virtual machine click the button in the lower left that looks like two arrowheads pointing at each other with a blue background. Select connect current window to host at the top of the window. Your host is going to be the same as we used to connect earlier using the ssh command so type user at server for me it's john at vm it'll ask you to select the platform of the server so select linux after a bit you'll be connected click open folder and it'll let you select one at the top i'm going to select hello dash world dash c which is the source code we cloned or downloaded earlier confirm this folder by hitting okay now it'll ask us if we trust the authors in this case i trust myself so i'll click yes i trust the authors before doing that i'll select trust the authors of all files in the parent folder since those are the files on this virtual machine now this is our environment we can see a list of folders and files on the left we'll open a new terminal first by clicking terminal then new terminal or using the keyboard shortcut this terminal is running on our virtual machine so any commands here actually run on the virtual machine at this point you shouldn't have to use the git bash terminal on windows unless things go wrong just to make sure things work let's compile our code type meson space setup space build this will set up a build directory for us now we can compile it by typing meson space compile space dash capital c space build now there's going to be an executable program in that build directory we can run type build slash hello dash world and press enter to run it it should run the program and print hello world the next thing we're going to do is add autocomplete to our source code open the src or source directory on the left and open the hello dot c file this is the file we compiled and made the hello world executable from we're going to go back to extensions except this time we'll install the extension on the virtual machine open extensions again and search for clang d click install beside it and wait for it to finish installing now we can look at our source code again select the file explorer from the top left and navigate back to hello dot c you should see that print f now tells us that the argument we used is called format you'll also have autocomplete and a bunch of other useful things next we're going to apply some settings to our developer tools on the virtual machine we're going to type git space config space dash dash global before all these commands so they're applied to every git repository you use first we'll set user dot name minus quote jonathan end quote now we'll set our email type the config command again then user dot email then your email i'll use my work email next option is init dot default branch with the capital b space main now poll dot rebase space false our final git option is alias dot lol space quote log dash dash pretty equals one line space dash dash a brief dash commit space dash dash graph space dash dash decorate end quote the last command actually added a new git command you can now type git space lol and get this fun little display that i'll explain later let's change our default compiler to one using more modern practices type sudo space update dash alternatives space dash dash set space cc space slash user slash bin slash clang type your user password and now we'll have clang as our default compiler now we can install oh my zsh search for it on google and it should be the first link there click the install oh my zsh link and click install oh my zsh via w git you can copy this command to save you some typing switch back to vs code and paste it into the terminal it'll download and ask you to change your default shell confirm by typing y and pressing enter you may need to type your user password for sudo after a bit you'll have a new terminal prompt you can keep it like this if you like the look of it but if you want to change it type nano space dash w space tilde slash dot zsh rc you can use the arrow keys to go down the line that starts with zsh underscore theme change the name in the quotes from robby russell to luke randall to save the changes hold control and press o next scroll down a bit more until you find the plugins line add ssh dash agent in addition to git if you set a passphrase an ssh agent will save your passphrase so you don't have to constantly type it save your changes again by holding control and pressing o now exit by holding control and pressing x now we'll see our new prompt by holding control and pressing d to disconnect from the shell now type zsh and hit enter to see the new prompt congratulations you're ready to use vs code on windows for remote ssh development to a linux machine in this video we use our linux virtual machine set up in the previous video but you could do remote development on any machine you have access to for example you could use amazon cloud servers or beefy gpu machines for machine learning