Sitemap
Stoicdailydose

Stoicdailydose

Smbclient command

2 min readMar 20, 2023

There are two different methods to connect to a Samba file server. These are:

Connecting from the terminal with the smbclient command
Connect from the file system by typing an address in the form “smb://filename”.
In this article, we will examine the smbclient command to connect to the samba file server and drive transactions from the terminal. Let’s get started :)

Smbclient is a command line tool similar to an FTP connection. This command provides access to SMB resources. Common smbclient commands are as follows:

List SMB shares:

smbclient -L //server_name -U users

SMB sharing: (Password must be entered.)

smclient //server/share -U user

Direct connection to SMB sharing: (No password required, but the password appears on the screen.)

smclient //server/share -U user%password

Common smbclient flags for more specific uses are listed below:

The “-L” flag ( — list) is the flag used to list shares on the server.

The “-U” flag ( — username [%password]) is the flag used to specify the username (and optionally password) to be used to log into the file server to be connected to.

Get Stoicdailydose’s stories in your inbox

Join Medium for free to get updates from this writer.

The “-a” flag ( — authentication-file) is the flag used to specify the file that holds the user-password information to establish a connection. The format of the file to be specified should be as follows.

“-B” flag ( — browse): This flag uses DNS to find SMB servers.

The “-p” flag ( — port) is used to select the port to which the connection is to be made. If this flag is not used, the default port is port 139.

The “-I” flag ( — IP-address IP-address) is used to give the IP address of the server, not the NetBIOS name, for the connection.

Flag( — — kerberos): Used to try to authenticate with Kerberos.

Flag ( — debuglevel) is a flag that provides more detailed information to log files. a value of 0–10 can be given.

In addition, you can connect with smbclient in different ways. These are:
1) the name of the server NetBIOS:

smbclient -L fileserver

2) with the IP address of the server:

smbclient -L x.x.x.x

3) with a direct link to a share using backslash:

smbclient \\\\fileserver\\share

4) the above option can also be performed using quotation marks:

smbclient "\\fileserver\share"

--

--