Connect Visual Studio Remote to a Laravel Forge Managed Server on Windows 10.
This is a setup guide on how to connect Visual Studio Code (SSH) to a Laravel Forge Managed Server.
- Laravel Forge
- Visual Studio Code
- Remote Development Extension
- Windows 10 (This guide was made for windows 10)
This guide will not be going over how to provision a laravel forge server. For information on this I recommend this series form LaraCasts: Learn Forge.
Install Visual Studio Code, Remote Development Extension.
Go to Apps & Features in windows, click Manage optional features then Add a feature, then find OpenSSH Client and OpenSSH Server and activate them. If they do not appear in the list, check and see if they were already installed by backing out and looking for them inside the list.
Open Command Prompt and run
ssh-keygen -t rsa -b 4096
this will create the needed private and public key's on your computer in the folder C:/users/{username}/.ssh/
PLEASE NOTE: if you use an existing generated key pair, or putty, you will run into permissions errors.
Open up the public key that was created @ C:/users/{username}/.ssh/id_rsa.pub
with note pad or visual studio code, copy then contents and paste into the SSH Keys on Forge. Then click Apply.
Launch Visual Studio Code, then click on the Remote-SSH tab, then click the gear icon to the right of connections then click the first file the appears in the dropdown.
Replace the file with the following template:
# Read more about SSH config files: https://linux.die.net/man/5/ssh_config
Host {host}
HostName {insert-ip}
User forge
IdentityFile C:\Users\{insert-username}\.ssh\id_rsa
StrictHostKeyChecking no
Host: is used just for reference HostName : public IP of the forge server you created. IdentityFile : points to the private key you made in step 4. just place your desktops username in the curly bracket.
Click save once done.
click on the Remote-SSH tab, then right click on the host you just created and launch the connection. Your all done!
If this guide helped you at all, please star so others will find it. If it was not helpful, let me know why. Have a wonderful day.
If you dont change a settings in filesystem, visual studio code and detect changes. run the command
sudo nano /etc/sysctl.conf
Then change the value if present, or add this to the end of the file
...
fs.inotify.max_user_watches=524288
...