Samba Client for Windows – smbclient.exe – v3.6.25

So in reference to getting Pydio working on a Windows Server 2012 R2 machine with IIS 8.5 I found that I wanted a workspace in Pydio to access a existing share on a 2012 R2 file server. I have a lot of files I don’t want duplicated on both servers. Now there are many workspace drivers available but since Pydio was designed originally for a *nix system the main way to access a Windows server is through Samba. Windows Server supports SMB, server message blocks, for file sharing among other things. Now on a *nix system you can just install Samba and then Pydio can use the Samba client to remotely access the Windows server. Problem is I want to use Samba on a Windows server to access another Windows server. So I started a hunt to find a ported version of the Samba client and it resulted in two pages out of the millions out there: https://smithii.com/samba which had ported all of Samba v3.0.23 over and https://www.leepa.io/lpackham/smbclient/ which had ported just the v3.0.7 client. So I started testing these clients and long story short they have issues with Windows servers. Mainly you can get directory listings using them and even pull files but you cannot create files nor push files to the Windows file server. After some research its due to changes, mainly security related, in the Windows servers SMB implementation….changes that were fixed in newer versions of Samba (https://www.samba.org/).

So I determined that the only possible way to get my Pydio install to access my existing Windows file server was to either use the FTP over SSH plugin and enable this on my file server, which I didn’t want to do, or figure out a way to compile the Samba client using the latest source. After lots of trail and error I was able to partially compile Samba 3.6.25 using Cygwin (https://www.cygwin.com/) but where it failed was after it had built the smbclient.exe that I needed. I took the client and copied it to the server and tried running it from a command prompt and it complained about needing some Cygwin DLL files which was expected. I copied over the DLL files it needed to the server and was able to connect to the file server. I then updated Pydio to use my newly compiled smbclient.exe and Pydio now works as expected allowing e to share out a existing share from another server. The best part is since user credentials are passed through the existing NTFS permissions still apply on top of Pydios own permission checks.

Not sure if anyone in the world will ever need it but just in case here it is: smbclient.zip. Keep in mind you will need to install Cygwin on the same machine and at the very least copy the DLL files it needs out of C:\cygwin\bin to the directory with the client.

10 thoughts on “Samba Client for Windows – smbclient.exe – v3.6.25

    1. I’m glad someone other then me will be using it. Please try the updated guide and let me know how it worked out. Also if you end up having a 2016 windows file share I’d be curious to know if the samba client can access that successful.

      1. Hi Man i’m trying to use it on my machine, but it’s said that the application cannot start correctly.
        can you please upload the working directroy to githb or to share it with me somehow?
        10x

        1. Due to the licensing I don’t think I can upload the Cygwin binaries. You’ll have to follow the guide to download and install Cygwin which will give you the libraries (DLL files) you’ll need and then try running it again.

  1. Thanks a lot. I was searching exactly for that option. Please give me a hint where I have to copy the smblient.exe to or where its defined in PHP/Pydio whatever.. I’ve not much experience on Webservers.. Thanks for help

  2. Make sure to install cygwin packages openssh, libopenldap2_4_2, libattr1 in order to resolve the dll dependancies for samba (EG cygcom_err-2.dll, cyglber-2-4-2.dll)

  3. Getting a version of smbclient.exe that is enabled for SMB3 encryption would be ideal. I’ve tried the build of 4.6, but it crashes on perl components.

    I think the minimum version that will do this is 4.1.

    1. Unfortunately Samba v4+ changed to a new build system. I have tried unsuccessfully to build a 4+ client on Windows and have given up after wasting 30+ hours on it.

  4. I realize this is a few _years_ after the fact, but a quick FYI on this very helpful port of smbclient to Windows…

    1) I think the instructions above are silent on the fact that the binaries, as provided, are only for Cygwin32, not Cygwin64. The executable fails silently on Cygwin64. Not a big deal — I just installed a Cygwin32 instance beside my Cygwin64 one. Tip: don’t _ever_ use spaces in your Cygwin root directory name (ex: “C:\cygwin32” and “C:\cygwin64” are OK but “C:\cygwin 32” isn’t) — that’s not specific to your tool just a hard-won lesson in life.

    2) Your smbclient port successfully works over SSH tunnelling to get all the way to your SMB host (whether that’s a SAMBA or native Win host). For example, I successfully used PuTTY on my Windows 10 client to create an SSH tunnel (Local: 127.1.1.1:50445 Remote: 192.168.123.45:445) all the way to my SMB server. Then, in the cygwin32 shell, I simply ran: “smbclient -U whatever -p 50445 //127.1.1.1/sharename”. Works like a charm, and decent throughput eve. That means this smbclient port works perfectly over TCP-only CIFS, including over SSH-encapsulated/tunneled connections. Fantastic way to avoid VPN’s if needed (assuming you have an SSH server behind the firewall that you can reach). Verrrrry handy for command-line gymnastics on a Windows client accessing some remote SMB host, where you don’t want to worry about firewall transversal commands/etc. Also allows for use in your Cygwin32 environment, any portable Bash scripts taken from Linux sources, which may depend on smbclient and ssh command-line tunneling.

    3) Your port works perfectly on my up-to-date as of Oct. 31, 2019, Windows 10-64-bit environment with latest cygwin32.

    4) Thanks so much for this. Ever thought of getting the package onto the public Cygwin repository? Perhaps a recompile to Cygwin64 as well?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.