使用webdav server 连接

参考 https://blog.csdn.net/SilentCWQH/article/details/127559615

pkg i apache2
cd $PREFIX/etc/apache2
nano httpd.conf

httpd.conf把下面行前面的#去掉并保存:

LoadModule dav_module libexec/apache2/mod_dav.so
LoadModule dav_fs_module libexec/apache2/mod_dav_fs.so
LoadModule dav_lock_module libexec/apache2/mod_dav_lock.so
LoadModule auth_digest_module libexec/apache2/mod_auth_digest.so
Include etc/apache2/extra/httpd-dav.conf

看一下Listen哪个端口,默认应该是8080,可以按自己需要修改,特别是端口被占用的情况:

Listen 8080

nano httpd-dav.conf修改其中内容,设置别名和真实路径,我设置的是downloads路径,也可以设置storage/shared路径,可以访问手机全盘:

Alias /downloads "/data/data/com.termux/files/home/storage/downloads"
<Directory "/data/data/com.termux/files/home/storage/downloads">

创建webdav的账号密码,似乎必须是admin,以和上面httpd-dav.conf中的内容对应起来

htdigest -c "/data/data/com.termux/files/usr/user.passwd" DAV-upload admin

创建密码。这儿如果忘记了也没有关系,重新运行一次这个命令再创建新密码就行了。

启动服务:

httpd -k start

如果要重启服务,可以先用pkill httpd杀掉服务再启动。
如果有什么异常。查看log,在$PREFIX/var/log/apache2/

客户端

参考:https://www.jianshu.com/p/7ba5f0756efc

MAC上用finder>前往>连接服务器添加如:http://192.168.2.2:8080/downloads这样的形式即可连接访问。用户名admin,密码就是上面创建的那个。

其他推荐的软件还有RailDrive, bitkinex. windows上使用可在本站搜索 webdav参考群晖搞机的文章。

启用samba server,并通过windows连接

termux 安装samba

pkg install samba
cp $PREFIX/share/doc/samba/smb.conf.example $PREFIX/etc/samba/smb.conf
cd $PREFIX/samba
cp smb.conf smb.conf.backup
nano smb.conf

主要是启用guest登录,并设置共享路径。修改:

map to guest = Bad User
guest ok = yes
path = @TERMUX_HOME@/storage/shared

path应该不需要改,默认是共享sdcard全盘的。
启动smb服务:smbd。如果报错,有可能是有的软件不配套,更新一下:

pkg update
pkg upgrade
smbd

注意,由于android限制端口, smbd默认启动端口是4445,而windows默认是445端口。termux在很多手机上是不能提权为root的。
这儿有一个问答:https://superuser.com/questions/702948/how-to-mount-a-samba-share-on-non-standard-port似乎能解决,因为要下载运行一个脚本,暂未测试。
第一个答案:

This is possible! It's been a good few years, but combining a loopback interface tutorial I found with portions out of @Mike's [..link-only] answer (multihost version) I've created a script that can do this for you.

You can use this after running Install-Module -Name LoopbackAdapter -MinimumVersion 1.2.0.0 in an admin terminal (dont forget to dot-source the script so you can call this).

Create-Host -Name bob -Ip 10.254.0.1 -Dest ipOfHostname -Port port
which [upon reboot] will allow you to go to \bob (fake IP 10.254.0.1) which attaches to your "hostname:port" from your question.
This will persist across boots and you don't need to re-run it if the source server goes up or down; teardown is as simple as Retire-Host -Name bob.

That easy, one command, programmatic, no gui/windows settings dialogs; but feel free to follow along below manually.

翻译过来就是:先在powerscript用admin运行Create-Host -Name bob -Ip 10.254.0.1 -Dest ipOfHostname -Port port,然后运行作者的ps1脚本https://gist.github.com/Hashbrown777/081e57ff9673a1f457e1c3a71b55cfaf#file-attachsmb-ps1-L61, 然后就可以使用\\bob连接目标设备了。

标签: none 阅读量: 1841

添加新评论