Connecting to a Windows Shared Drive from CentOS using smbclient

What is the quickest way to access a Windows Shared Drive from CentOS ? Use smbclient !

It’s an FTP-like client to access SMB/CIFS resources on a server and its part of the “samba-client” package which is installed by default on CentOS.

[laurent@localhost Downloads]$ rpm -qf /usr/bin/smbclient

The firewall is pre-configured so you don’t need to change anything to use it:

If you look on the internet, you’ll find lots of posts telling you to use this syntax: smbclient [SHARED_DRIVE_UNC_PATH] -U [username]. But if your target Windows server belongs to a domain, you’ll get an NT_STATUS_LOGON_FAILURE error:

[laurent@localhost Downloads]$ smbclient // -U laurent
Enter laurent's password:
session request to failed (Called name not present)
session setup failed: NT_STATUS_LOGON_FAILURE

That’s because the domain name must be provided using the -W option. Also (and I must say that I lost a couple of minutes before of this), the password that you must enter is the one from the domain you want to connect to, not the one from your local Linux account.

[laurent@localhost Downloads]$ smbclient // -U laurent -W entropysoft
Enter laurent's password:
Domain=[ENTROPYSOFT] OS=[Windows 7 Professional 7601 Service Pack 1] Server=[Windows 7 Professional 6.1]
 smb: \>

From there, you can navigate in the target system using the “ls” & “cd” commands and upload/download files using the “put” & “get” commands: see the smbclient man pages for more information.

smb: \> ls
 . DR 0 Fri Oct 5 09:27:04 2012
 .. DR 0 Fri Oct 5 09:27:04 2012
 activity_lifecycle.png A 82637 Mon Sep 3 14:01:54 2012
 AllowImperso.ps1 A 387 Mon Dec 12 16:03:37 2011
 amazon.pem 1696 Thu Aug 30 13:17:43 2012
 amazon.ppk A 1464 Wed Sep 12 19:41:54 2012

37897 blocks of size 8388608. 17669 blocks available
smb: \> get activity_lifecycle.png
getting file \activity_lifecycle.png of size 82637 as activity_lifecycle.png (2017.5 KiloBytes/sec) (average 2017.5 KiloBytes/sec)
smb: \>



Connecting to a Windows Shared Drive from LXDE using Gigolo

When using Ubuntu or/and GNOME, there are many ways to connect to a Windows shared drive… but how can we do this from LXDE ?

Well, you don’t need to install samba, you just need to use Gigolo:

Once Gigolo is started, it will happily sit in your taskbar: this is important to know since closing the application by clicking on the X icon will not really close it, but will put it back in the taskbar. You need to use the “File > Quit” option to correctly close it.

Using the “Help > Supported protocols” option will display the list of supported protocols. The only we are interested in is called “Windows Share (smb)”. If you don’t see it, then you need to install the gvfs-smb package using yum.

From there, click on “Connect”, choose “Windows Share” as the service type and enter your username/password/credentials:

Et voilà: just right-click on the newly established connection and choose the “Open” option to see the files in the shared drive:

If you want to re-use your connection after closing and re-opening Gigolo, you need to create a bookmark:

The next time you open Gigolo, click on the bookmark dropdown list to display the list of existing bookmarks:


Killing a hanged Windows service

A hanged service looks like this (as you can see, all Start/Stop/Pause/Resume buttons are disabled):

To kill this service, first note the service name. On the screenshot above, it is ‘EntropySoftCFS’ (ie: the first thing displayed in the “General” tab).

Then, open a DOS shell and run the ‘sc queryex’ command to retrieve the service PID, then use the ‘taskkill’ command to… well, kill it !

C:\>sc queryex EntropySoftCFS

TYPE               : 10  WIN32_OWN_PROCESS
STATE              : 2  START_PENDING

WIN32_EXIT_CODE    : 0  (0x0)
CHECKPOINT         : 0x1
WAIT_HINT          : 0xbb8
PID                : 3756
FLAGS              :

C:\>taskkill /PID 3756 /F
SUCCESS: The process with PID 3756 has been terminated.