Connecting to Samba shares on Linux / One-way Sync

Using Samba (or SMB) shares on Linux is not difficult but you should know some tricks. First of all, you can use smbclient to probe your Samba-Server and try to connect to it. You can then mount an SMB-share locally.
In addition, I wrote a tool to synchronize a local directory with a Samba server (without mounting it) via Python. Scroll down for more details.

Using smbclient

To install smbclient and nmap on Arch Linux, do:

pacman -Sy nmap smbclient

Then you can use nmap, nmblookup and smbclient to communicate with your Samba server:

nmap -p 139 192.168.1.4

nmblookup -A 192.168.1.4

smbclient -L //COMPUTER_NAME/ -I 192.168.1.4 -U philipp

# This finally gives you a FTP like prompt:
smbclient //COMPUTER_NAME/Storage -I 192.168.1.4 -U philipp

More:

Mounting a Samba Share

Source

mount -t cifs //SERVER/sharename /mnt/mountpoint -o user=username,password=password,workgroup=workgroup,ip=serverip

One-Way Sync With Python

To synchronize a local folder to a folder on a SMB-share, I developed smbsync.py. It makes use of pysmb, a pure Python implementation of the client-side SMB/CIFS protocol.

usage: smbsync.py [-h] --server_ip SERVER_IP --share SHARE [--domain DOMAIN]
                  [--username USERNAME] [--password PASSWORD]
                  [--server_name SERVER_NAME] [--verbose]
                  from_path to_path

One-way sync to an SMB/CIFS server (needs pysmb)

positional arguments:
  from_path             Local path to sync to the share
  to_path               Path in the share to sync to

optional arguments:
  -h, --help            show this help message and exit
  --server_ip SERVER_IP, -i SERVER_IP
                        SMB/CIFS Server IP
  --share SHARE, -s SHARE
                        Name of the share
  --domain DOMAIN, -d DOMAIN
  --username USERNAME, -u USERNAME
  --password PASSWORD, -p PASSWORD
  --server_name SERVER_NAME, -n SERVER_NAME
                        SMB/CIFS Server Name (optional)
  --verbose, -v         Make this tool more verbose

Resources

Comments