最近在项目中安装和调试服务器,杯具的是,服务器是内网地址,并且不能够直接SSH、SFTP,只能经过中间一台linux做为跳板,而后在SSH命令行里去操做目标机器。linux
若是只是命令行操做也就无所谓了,可是还要常常传输文件,在跳板机上SSH,SFTP,SCP命令切换过来切换过去,累死了,有没有更好的办法?web
依稀记得N年前折腾过一个经过http协议操做服务器文件的玩意,那就是WebDAV。apache
科普开始。WebDAV (Web-based Distributed Authoring and Versioning) 一种基于 HTTP 1.1协议的通讯协议。它扩展了HTTP 1.1,在GET、POST、HEAD等几个HTTP标准方法之外添加了一些新的方法,使应用程序可直接对Web Server直接读写,并支持写文件锁定(Locking)及解锁(Unlock),还能够支持文件的版本控制。更多说明,请自行百度谷歌。好比,能够经过打开 http://127.0.0.1/uploads/ 来操做服务器上指定目录的文件,很是方便,解决了某些单位网络端口和防火墙的限制。windows
WebDAV配置浏览器
WebDAV服务端,目前我只折腾过Apache httpd,其余的我还不了解。从apache httpd官网下载好httpd 2.x版本,下载安装,完毕以后,打开httpd.conf文件,将最后几行的一个注释去掉。服务器
1 # Distributed authoring and versioning (WebDAV) 2 Include conf/extra/httpd-dav.conf
而后编辑conf/extra/httpd-dav.conf文件网络
# # Distributed authoring and versioning (WebDAV) # modified by longware # Required modules: mod_dav, mod_dav_fs, mod_setenvif, mod_alias # mod_auth_digest, mod_authn_file # #LoadModule dav_module modules/mod_dav.so #LoadModule dav_fs_module modules/mod_dav_fs.so #LoadModule alias_module modules/mod_alias.so #LoadModule auth_digest_module modules/mod_auth_digest.so #LoadModule authn_file_module modules/mod_authn_file.so # The following example gives DAV write access to a directory called # "uploads" under the ServerRoot directory. # # The User/Group specified in httpd.conf needs to have write permissions # on the directory where the DavLockDB is placed and on any directory where # "Dav On" is specified. DavLockDB "D:/WebServer/apache/var/DavLock" Alias /uploads "D:/WebServer/apache/uploads" <Directory "D:/WebServer/apache/uploads"> Dav On Order Allow,Deny Allow from all AuthType Digest AuthName DAV-upload # You can use the htdigest program to create the password database: # htdigest -c "D:/WebServer/apache/user.passwd" DAV-upload admin AuthUserFile "D:/WebServer/apache/user.passwd" AuthDigestProvider file # Allow universal read-access, but writes are restricted # to the admin user. <LimitExcept GET OPTIONS> require user admin </LimitExcept> </Directory> # # The following directives disable redirects on non-GET requests for # a directory that does not include the trailing slash. This fixes a # problem with several clients that do not appropriately handle # redirects for folders with DAV methods. # BrowserMatch "Microsoft Data Access Internet Publishing Provider" redirect-carefully BrowserMatch "MS FrontPage" redirect-carefully BrowserMatch "^WebDrive" redirect-carefully BrowserMatch "^WebDAVFS/1.[0123]" redirect-carefully BrowserMatch "^gnome-vfs/1.0" redirect-carefully BrowserMatch "^XML Spy" redirect-carefully BrowserMatch "^Dreamweaver-WebDAV-SCM1" redirect-carefully
上面的代码中,LoadModule部分,请根据本身状况开启,若是主httpd.conf文件中都开启了,此处就不用开启,反之,在这里要加上LoadModule。app
而后在apache的bin目录里,在cmd模式里,执行命令 ide
htdigest -c "D:/WebServer/apache/user.passwd" DAV-upload admin
会提示输入密码,此处就会生成一个用户名和密码对应的库文件。工具
而后重启apache,在浏览器地址栏输入http://127.0.0.1/uploads/,若是看到403禁止访问,应该就是配置成功了。
此配置文件适用于Linux系统,本人已配置成功,以前折腾了好久,走了弯路,汗!若是想成功在客户端操做文件,必需要将apache的默认运行用户daemon和目标文件夹设置为同一用户,或者同一组,或者本身更改apache的默认用户。
WebDAV客户端
一、最简便的客户端工具,就是windows的资源管理器(建议win7以上操做系统),打开个人电脑,右键“添加一个网络位置”,而后根据向导,输入地址http://127.0.0.1/uploads/,须要验证的时候,输入口令,就在个人电脑里建立了一个网络文件夹,双击打开,就能够自由操做文件了。
使用windows的资源管理器的优势是方便,缺点是,我感受操做和响应有点慢,因而乎,我在寻找其余工具。
要5.7以上版本,以前的版本不支持。winscp界面友好,操做很方便,推荐。
若是你常常比较文件和文件夹,推荐Beyond Compare,我从2.0开始用的,很是好。进行比较文件夹时,能够选择其余文件系统,选择webdav便可。Beyond Compare 4才支持webdav,之前的版本不支持。
四、其余
BitKinex、Cyberduck、WebDrive、DAVExplorer、FarNetBox、AnyClient等等,我试用了下,感受都怎么的不那么好用,要不UI不够友好,要不功能不够强大。
更多工具参考这里,有些free有些收费。