smbclient is a command-line SMB/CIFS client from the Samba suite. Think of it as an FTP-like shell for Windows file shares (and Samba servers). It supports NTLM/Kerberos authentication, SMB2/3, encryption, and both interactive and scripted operation.
Quick Start
# List shares (anonymous / guest attempt)smbclient -L //TARGET -N# List shares with username (prompt for password)smbclient -L //TARGET -U alice# Connect to a share interactivelysmbclient //TARGET/Share -U alice# One-liner to fetch a file (non-interactive)smbclient //TARGET/Share -U alice -c "get report.xlsx"# Kerberos (after kinit)kinit alice@EXAMPLE.COMsmbclient //filesrv01/Share -k# Scripted recursive downloadsmbclient //TARGET/Share -U alice -c "recurse; prompt OFF; mget *"
Installation
Debian/Ubuntu: sudo apt install smbclient
RHEL/CentOS/Fedora: sudo dnf install samba-client (or samba-client/samba depending on distro)
macOS (Homebrew): brew install samba (binary is smbclient)
Windows: Use WSL or a Unix-like environment; native Windows clients include net use and PowerShell cmdlets rather than smbclient.
Once connected, you get an FTP-style prompt. The most useful commands:
? or help # list commandsls, dir # list directorycd, lcd # change remote / local directorypwd, lpwd # print remote / local directoryget FILE # download filemget PATTERN # download multiple (respects mask/prompt)put FILE # upload filemput PATTERN # upload multiplerecurse ON|OFF # recurse into subdirectories for m* commandsprompt ON|OFF # confirm each transfer or notmask PATTERN # set a filter (e.g., mask *.docx)mkdir DIR # create directoryrmdir DIR # remove directorydel FILE # delete fileallinfo FILE # show metadata on a fileexit, quit # close session
Examples
# Download an entire share treesmb: \> recurse ONsmb: \> prompt OFFsmb: \> mget *# Targeted grab by typesmb: \> mask *.xlsxsmb: \> mget *# Upload a filesmb: \> put ./toolkit.ps1 \\Tools\\toolkit.ps1
Typical Workflows
1) Share Enumeration
# Null/guest trysmbclient -L //filesrv01 -N# With creds (domain or local)smbclient -L //filesrv01 -U EXAMPLE\\alice
2) Browse & Pull Files
# Connect and browsesmbclient //filesrv01/Finance -U EXAMPLE\\alice# Non-interactive one-shotsmbclient //filesrv01/Finance -U alice -c "cd Q4; get budget.xlsx"
# Useful for testing known hashes without crackingsmbclient //dc01/C$ -U EXAMPLE\\Administrator --pw-nt-hash# (Will prompt for the 32-hex hash instead of a password)
5) Force Protocols (troubleshooting old/new servers)
# Modern default: require SMB2+smbclient //old-nas/Public --option='client min protocol=SMB2'# If you MUST talk to legacy SMB1/NT1 (not recommended):smbclient //very-old-nas/Public --option='client min protocol=NT1' --option='client max protocol=NT1'
# Bash example: nightly pull of reportssmbclient //filesrv01/Reports -A /root/.smbauth -c "recurse; prompt OFF; mget *" \ && echo "Reports synced at $(date)"
Comparison: smbclient vs. Mounting
smbclient: transient, FTP-like, great for quick tasks, enumeration, and scripted copies; runs as your process context.
mount.cifs: permanent mount point; integrates with filesystem semantics (useful for apps, rsync, etc.). Requires kernel CIFS module and typically root or proper fstab options.
Authentication Modes
Anonymous/Guest: -N or -U 'guest%' if enabled on the server.
Username/Password (NTLM): -U user (prompts) or -U 'user%pass' (avoid leaving in shell history).
Kerberos (SSO): -k after kinit; respects ticket lifetime and SPNs.
NT Hash: --pw-nt-hash (build-dependent).
Domain vs Local Accounts: Specify domain with -W or DOMAIN\\user.
Security tip: Prefer Kerberos. Avoid putting cleartext passwords on the command line or in world-readable auth files.
Name Resolution & Targeting
Use -I to connect by IP if NetBIOS/DNS names are unreliable:
smbclient //filesrv/Share -U alice -I 10.10.10.25
If the server expects a specific NetBIOS name, you can export CLIENT_NTLMV2_AUTH=yes and set --option='client use spnego = yes' (often default). In AD/Kerberos environments, proper DNS and SPNs are key.
Troubleshooting & Gotchas
NT_STATUS_ACCESS_DENIED: Bad creds or insufficient share/NTFS permissions. Try another user or check both share & NTFS ACLs.
Protocol negotiation failures: The server may have SMB1 disabled (good). Use SMB2/3:
smbclient //server/share --option='client min protocol=SMB2' --option='client max protocol=SMB3'
Conversely, very old devices may require NT1 (avoid where possible).
Kerberos fails, NTLM works: Check time sync, SPNs, DNS, and that klist shows a valid TGT.
Uploads succeed but files vanish: AV or FSRM quotas/screens may remove/quarantine. Check server policies.
Unicode/charset issues: Try --option='client character set = UTF-8'.