SMB / CIFS

SMB / CIFS

SMB 是 一种用于在网络上共享文件的通信协议

它依赖 go - smb2 库 来与 SMB 协议进行通信。

路径指定为 remote:sharename(对于 lsd 命令则使用 remote:)。你也可以指定子目录,例如 remote:item/path/to/dir

注意事项

路径的第一段必须是共享名,这是你在 Windows 上开始共享时输入的名称。在 smbd 上,它是 smb.conf(通常位于 /etc/samba/)文件中的节标题。 如果你不确定,可以通过查询根目录来查找共享(例如 rclone lsd remote:)。

显然,你无法通过 rclone 访问共享打印机。

你不能使用匿名访问进行登录。相反,你必须使用空密码的 guest 用户。 rclone 客户端在上传文件时会通过对尾随空格和句号进行编码来避免使用 8.3 文件名。 另外,Windows 上的 本地后端 可以使用 UNC 路径(\\server\share)访问 SMB 服务器。但这不适用于非 Windows 操作系统,如 Linux 和 macOS。

配置

以下是一个进行 SMB 配置的示例。

首先运行

rclone config

这将引导你完成一个交互式的设置过程。

No remotes found, make a new one?
n) New remote
s) Set configuration password
q) Quit config
n/s/q> n
name> remote
Option Storage.
Type of storage to configure.
Choose a number from below, or type in your own value.
XX / SMB / CIFS
   \ (smb)
Storage> smb

Option host.
Samba hostname to connect to.
E.g. "example.com".
Enter a value.
host> localhost

Option user.
Samba username.
Enter a string value. Press Enter for the default (lesmi).
user> guest

Option port.
Samba port number.
Enter a signed integer. Press Enter for the default (445).
port> 

Option pass.
Samba password.
Choose an alternative below. Press Enter for the default (n).
y) Yes, type in my own password
g) Generate random password
n) No, leave this optional password blank (default)
y/g/n> g
Password strength in bits.
64 is just about memorable
128 is secure
1024 is the maximum
Bits> 64
Your password is: XXXX
Use this password? Please note that an obscured version of this 
password (and not the password itself) will be stored under your 
configuration file, so keep this generated password in a safe place.
y) Yes (default)
n) No
y/n> y

Option domain.
Domain name for NTLM authentication.
Enter a string value. Press Enter for the default (WORKGROUP).
domain> 

Edit advanced config?
y) Yes
n) No (default)
y/n> n

Configuration complete.
Options:
- type: samba
- host: localhost
- user: guest
- pass: *** ENCRYPTED ***
Keep this "remote" remote?
y) Yes this is OK (default)
e) Edit this remote
d) Delete this remote
y/e/d> d

标准选项

以下是 SMB(服务器消息块/通用 Internet 文件系统)特定的标准选项。

–smb-host

要连接的 SMB 服务器主机名。

例如:“example.com”。

属性:

  • 配置项:host
  • 环境变量:RCLONE_SMB_HOST
  • 类型:字符串
  • 是否必需:是

–smb-user

SMB 用户名。

属性:

  • 配置项:user
  • 环境变量:RCLONE_SMB_USER
  • 类型:字符串
  • 默认值:"$USER"

–smb-port

SMB 端口号。

属性:

  • 配置项:port
  • 环境变量:RCLONE_SMB_PORT
  • 类型:整数
  • 默认值:445

–smb-pass

SMB 密码。

注意:输入的内容必须进行加密处理 - 请参阅 rclone obscure

属性:

  • 配置项:pass
  • 环境变量:RCLONE_SMB_PASS
  • 类型:字符串
  • 是否必需:否

–smb-domain

用于 NTLM 认证的域名。

属性:

  • 配置项:domain
  • 环境变量:RCLONE_SMB_DOMAIN
  • 类型:字符串
  • 默认值:“WORKGROUP”

–smb-spn

服务主体名称。

Rclone 会将此名称呈现给服务器。一些服务器会将其用于进一步的认证,并且在集群环境中通常需要设置该选项。例如:

cifs/remotehost:1020

如果不确定,请留空。

属性:

  • 配置项:spn
  • 环境变量:RCLONE_SMB_SPN
  • 类型:字符串
  • 是否必需:否

高级选项

以下是 SMB(服务器消息块/通用 Internet 文件系统)特定的高级选项。

–smb-idle-timeout

关闭空闲连接前的最长时间。

如果在指定时间内没有连接返回到连接池,rclone 将清空连接池。

设置为 0 可无限期保留连接。

属性:

  • 配置项:idle_timeout
  • 环境变量:RCLONE_SMB_IDLE_TIMEOUT
  • 类型:时长
  • 默认值:1 分 0 秒

–smb-hide-special-share

隐藏用户不应该访问的特殊共享(例如 print$)。

属性:

  • 配置项:hide_special_share
  • 环境变量:RCLONE_SMB_HIDE_SPECIAL_SHARE
  • 类型:布尔值
  • 默认值:true

–smb-case-insensitive

服务器是否配置为不区分大小写。

在 Windows 共享上始终为 true。

属性:

  • 配置项:case_insensitive
  • 环境变量:RCLONE_SMB_CASE_INSENSITIVE
  • 类型:布尔值
  • 默认值:true

–smb-encoding

后端的编码方式。

有关更多信息,请参阅 概述中的编码部分

属性:

  • 配置项:encoding
  • 环境变量:RCLONE_SMB_ENCODING
  • 类型:编码方式
  • 默认值:斜杠、尖括号、双引号、冒号、问号、星号、竖线、反斜杠、控制字符、右侧空格、右侧句号、无效 UTF-8、点号

–smb-description

远程存储的描述。

属性:

  • 配置项:description
  • 环境变量:RCLONE_SMB_DESCRIPTION
  • 类型:字符串
  • 是否必需:否