Ubuntu: Creating a Samba/CIFS share to quickly share files with Windows

ubuntuWe live in a multi-platform world, and the ability to easily share folders of content between users in the same protected network is a function made very convenient in the Windows world with CIFS shares (e.g. \\mydesktop\sharedfolder).

Luckily for Ubuntu users, it is pretty easy to setup CIFS shares to offer that same interoperability with Windows hosts on your network.  Start by installing the Samba components.

apt-get install samba -y

Then create the local Ubuntu user that the Windows user can connect as:

useradd test1

smbpasswd -a test1 (set to 'mypassword')

Now append the following section to /etc/samba/smb.conf, which will share the /tmp folder

[shared]
path = /tmp
available = yes
valid users = test1
read only = no
browsable = yes
public = yes
writable = yes

Note that ‘writable‘ and ‘browsable‘ may appear misspelled, but they are synonyms and work either way in the conf file.

Then Open the firewall for CIFS traffic

ufw allow 445
ufw allow 135
ufw allow 136
ufw allow 137

And now restart the SMB daemon

service smbd restart

From your Windows machine, pull up the IP or fully qualified domain name of the Ubuntu machine

\\<FQDN>

and you should see a single share named ‘shared’.  Click on it, and you will prompted for credentials, type in test1/mypassword, and you should now see the contents of your Ubuntu /tmp folder in Windows File Explorer.

Validate functionality by creating a file under /tmp, and having it accessible in Windows.  And conversely, create a text file within Windows explorer, and verify you see it show up in the Ubuntu /tmp directory.

 

REFERENCES

http://www.cyberciti.biz/faq/what-ports-need-to-be-open-for-samba-to-communicate-with-other-windowslinux-systems/

http://askubuntu.com/questions/649969/what-ports-does-the-samba-client-require

http://www.howtogeek.com/176471/how-to-share-files-between-windows-and-linux/

Ports used by various MS services