smbclient是Linux系统中用于访问Windows共享文件夹和打印机的Samba客户端工具,它允许用户在命令行界面与SMB/CIFS服务器进行交互。
在大多数Linux发行版中,smbclient通常包含在samba-client软件包中:
# Ubuntu/Debian
sudo apt install samba-client
# CentOS/RHEL
sudo yum install samba-client
# Arch Linux
sudo pacman -S smbclient
基本使用格式:
smbclient //server/share [选项]
smbclient -L //192.168.1.100 -U username%password
smbclient //192.168.1.100/shared -U username
连接成功后可以使用以下常用命令:
smbclient //server/share -U user -c 'ls'
检查防火墙设置,确保445端口开放:
sudo ufw allow 445
尝试使用不同的SMB协议版本:
smbclient -m SMB3 //server/share -U user
添加编码参数:
smbclient //server/share -U user --option='client unicode=yes'
sudo mount -t cifs //server/share /mnt/share -o username=user,password=pass
创建~/.smbclient.conf文件:
[global]
client min protocol = SMB2
client max protocol = SMB3