![cadaver 自动登录(WebDav 客户端)](https://linux22.com/image/551714/cadaver%20%E8%87%AA%E5%8A%A8%E7%99%BB%E5%BD%95%EF%BC%88WebDav%20%E5%AE%A2%E6%88%B7%E7%AB%AF%EF%BC%89.png)
我最近一直在使用 cadaver,但是有没有办法可以自动登录,例如一行代码:
尸体http://webdav.server.com用户=xxxxxxxxx 密码=xxxxxxxxxxx
我无法使用 davfs2,因为我的 VPS 无法安装 WebDav,因为它符合 FUSE 的规定。
答案1
您可以使用 .netrc 文件,但请注意,这存在安全风险。它包含未加密的 dav 帐户密码。您需要采取的一些预防措施包括:
- 请勿在其他任何地方使用该密码。
- 将 .netrc 文件权限设置为 400 或 600,并由运行 cadaver 的用户拥有。使用
- 如果可能的话,让尸体程序以仅运行脚本的用户身份运行。
这是来自 cadaver 手册页的 netrc 信息。
THE .netrc FILE
The file ~/.netrc may be used to automatically login to a server
requiring authentication. The following tokens (separated by
spaces, tabs or newlines) may be used:
machine host
Identify a remote machine host which is compared with the
hostname given on the command line or as an argument to
the open command. Any subsequent tokens up to the end of
file or the next machine or default token are associated
with this entry.
default
This is equivalent to the machine token but matches any
hostname. Only one default token may be used and it must
be after all machine tokens.
login username
Specifies the username to use when logging in to the
remote machine.
password string
passwd string
Specifies the password to use when logging in to the
remote machine.
Any other tokens (as described in ftp(1)) are ignored.
祝你好运,里克