简体   繁体   中英

Visual studio code live server on windows 10 and ssh

I am using visual studio code to edit html files and they are saved on a directory on Ubuntu and I am connected to a host on ssh using visual studio code.

The default browser in file preferences settings was set to null which means default browser, but when I clicked open live server on visual studio code it didn't open anything. I changed the setting to open firefox and it didn't open anything. I installed firefox live server extension and tried to open and it didn't open anything. When I first started using visual studio code it opened html files using the default null setting and opened the html file in Microsoft Edge. I don't remember if it was a directory on the local machine that I am using or not but it opened it. For some reason it stopped working. I have tried to open in live server on local files and ssh files and now it will not open with the null setting or firefox setting with the live server extension installed for firefox.

Is this happening because I am trying to connect to a ssh directory? If so do I need to somehow change ssh settings in visual studio code to open not localhost:5500 files and the ssh html files everytime.

Is it happening because I need to port forward the files coming from the ssh server on my router to port 5500, the ssh ubuntu servers ip address?

Even on the local machine it is not opening html files on the local machines c: drive in live server. Is this happening because I need to port forward on the router to the local host, the computer I am usings ip address?

I am confused about how it is pulling up the documents in a browser like it used to do with the ip address in the browser of 127.0.0.1:5500 or different port number. What if the html files I want to edit are not stored on the local host machine and are saved on a ssh Ubuntu server which would no longer be localhost it would be the ip address of the ssh server?

I am confused about why it is not working. Can someone please help me get it working, For ssh html files and local files on the c: drive?

To answer part of my questions yes you do have to port forward, but it is on visual studio code so when you are connected to a ssh machine, local host is not going to pull up the html files on that machine, because it is not a local host. so it can't connect to that servers ssh html files.

So you have to port forward in visual studio code to port 5500 or what ever port it says in the window at the bottom or on the bottom right side of the screen in for me it is port 5500 but I have had it give me a different port which was 5501 so what ever port number it gives you when the live server is started is the port you are going to want to use for port forwarding in visual studio code.

I forwarded to port 5500. You have to be connected using ssh. Then click on remote explorer on the left side of the visual studio code editor and then clicking the plus sign on forwarded ports then type in the port number for me it was 5500 and that will port forward it to the ubuntu or whatever other os ssh server you are using ip address.

At this time I am connected to a local area network so the ip adress is 192.168.88.xxx but if you connect to the ssh server using a domain name or the WANS ip address you will have to connect using port forwarding. On the router you will have to port forward to the ssh servers ip address port forwarding to for me it was port 5500 for you it might be a different port number. I think I might have saw a setting somewhere where you can chose the port number you want to use in virtual studio code, but you can look that up if you need to. I mentioned that because if you are not the administrator of the ssh network and can't forward the ports you want then you might have to use the port number that is given by that person.

Now that all that has been said on the Windows 10 machine that I use for editing on the local network I can type in a browser window if live server has been started on visual studio code on port for me 5500 the ubuntu ssh servers local ip address and the port number 192.168.88.xxx:5500 and it pulls up the live server in the browser that I choose to use. I can see everything that is being edited live. It works this way, (would also work with the WANS IP address or domain name with :5500 after that) but when I right click on the html code and click open live server nothing happens.

Is there a way I can change a setting so that it automatially connects me to the Ubuntu ssh server 192.168.88.xxx:5500 so when I edit in visual studio code I don't have to open a browser myself everytime and type 192.168.88.xxx:5500.

When I did click on open live server it was taking me to 127.0.0.1:5500 the local host ip address on port 5500. I don't see how that will work with ssh on a whole different ip address 192.168.88.xxx:5500 and port number 5500.

Can someone tell me how I can this working correctly and if there is a setting I need to change?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM