TrumanWong

smbclient

Interactively access samba server

Supplementary instructions

smbclient command belongs to the samba suite, which provides a command line to interactively access the shared resources of the samba server.

grammar

smbclient(options)(parameters)

Options

-B<ip address>: IP address used when transmitting broadcast packets;
-d<debugging level>: specifies the detailed level of events recorded in the log file;
-E: Send information to the standard error output device;
-h: display help;
-i<scope>: Set the NetBIOS name range;
-I<IP address>: Specify the IP address of the server;
-l<record file>: Specify the name of the record file;
-L: Display all resources shared by the server;
-M<NetBIOS name>: You can use the WinPopup protocol to send information to the host specified in the option;
-n<NetBIOS name>: Specify the NetBIOS name to be used by the client;
-N: No need to ask for password;
-O<Connection slot options>: Set the options of the client TCP connection slot;
-p<TCP connection port>: Specify the server-side TCP connection port number;
-R<name resolution order>: Set the order of NetBIOS name resolution;
-s<directory>: Specify the directory where smb.conf is located;
-t<server character code>: Set what character code is used to parse server-side file names;
-T<tar option>: Back up all files shared by the server and package them into files in tar format;
-U<user name>: Specify user name;
-w<working group>: Specifies the working group name.

Parameters

smb server: Specify the smb server to connect to.

Example

List shared folders provided by a certain IP address

smbclient -L 198.168.0.1 -U username%password

Use smbclient like ftp client

smbclient //192.168.0.1/tmp -U username%password

After successfully executing the smbclient command, enter the smbclient environment and the prompt appears: smb://>

There are many commands here that are similar to ftp commands, such as cd, lcd, get, megt, put, mput, etc. Through these commands, we can access the shared resources of the remote host.

Directly use the smbclient command once

smbclient -c "ls" //192.168.0.1/tmp -U username%password

and

smbclient //192.168.0.1/tmp -U username%password
smb:/>ls

The function is the same.

Create a shared folder

smbclient -c "mkdir share1" //192.168.0.1/tmp -U username%password

If the user shares //192.168.0.1/tmp in a read-only manner, it will prompt NT_STATUS_ACCESS_DENIED making remote directory /share1