How to view html file in remote unix server?

2019-03-15 13:22发布

I currently have an html file on a remote unix server that I ssh to. I have been using SFTP to constantly transfer it to my local machine to view it after my edits, but I am tired of this.

What is the best program/method for Mac users to have a browser window view of the html file that is stored in a remote unix server? Or is there an ssh client that can easily edit html files?

标签: html unix ssh
3条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-03-15 13:24

It is possible, but with some playing around on the server.

Once you have ssh'ed into the server, install a web server in that box. Say the file is named index.html, you should make it available at the URL http://localhost:8000/index.htmlor port number can be anything.

The simplest method I can think of starting a web server at that location is

cd /directory/where/html/is/present
python -m SimpleHTTPServer 8000  

This works provided python is installed on the server. It should not be that hard to install it as python is available from almost every package manager in every flavor of linux.

Now that html is available at python

http://localhost:8000/index.html

on that machine.

But we have not yet configured the browser in such way.

To do that you need to ssh into the server again, but with a -D option this time

ssh servername -D 7000

-D specifies application level tunneling when connecting via ssh

Then in firefox, preferences/options -> Advanced -> Networks -> Connection Settings -> Choose Manual Proxy configuration

SOCKS HOST should be localhost , port no 7000.

Then the html should be directly available at

http://localhost:8000/index.html

in your firefox browser. It is available only in firefox browser

查看更多
smile是对你的礼貌
3楼-- · 2019-03-15 13:30

You can mount the remote directory with sshfs which gives you easy access to all the files. E.g.:

sshfs user@server:/directory/to/mount /local/directory/
查看更多
神经病院院长
4楼-- · 2019-03-15 13:48

There are multitudes of editors for *nix. A very common one is vi (or vim) however you may be happier using something like nano - many of the people I've helped with this sort of thing like the key-bindings of nano better than they do vi. And of course emacs is very common on *nix.

查看更多
登录 后发表回答