Introduction

In this tutorial, I am going to talk about samba and ufw services. If you limit your file share within a dedicated range of ip addresses in your local network, your files are generally secure (from outside access), and still able to share files.

Installation

sudo apt-get install samba smbclient nautilus-share gufw

Add password for samba share

sudo smbpasswd -a yourusername

Note: Replace yourusername with your actual username

Rules

Add rules for samba in your firewall rules list. For this tutorial, I assume your computer’s ip starts with 192.168.0. E.g 192.168.0.100. Type following commands in a terminal.

sudo ufw allow from 192.168.0.0/24 to any app Samba

Sometimes, you might also want to execute some commands on your computer, using ssh. If you want to add ssh as well, execute following commands. For this you have to install ssh package first.

sudo apt-get install ssh sudo ufw allow proto tcp from 192.168.0.0/24 to any port 22 rm -rf .ssh # Only, if there is a problem with your previous key

Enable and start ufw

sudo ufw enable sudo service ufw start

Transmission

If you want to control Transmission via a web interface, you have to enable Transmission -> Edit -> Preferences -> Web -> Enable web client. Next, setup the authentication and add the respective port to ufw list, just as second rule (ssh) above.

sudo ufw allow proto tcp from 192.168.0.0/24 to any port 9091

You can also limit the ip addresses using Only allow these IP addresses to connect checkbox and adding respective ip addresses.

Conclusion

In this tutorial, we saw how we can add firewall and setup samba to share files. You can use some software like ES File Explorer in Android and copy files to or from your computer to your device. One thing you should note is, if you cannot access some services in your computer, first thing to do is disable ufw, access the service from external device and start exploring the rules needed to access that service through firewall. You can also use gufw to add or remove rules graphically.

Hope, this tutorial introduced you to file sharing on Linux via samba.

Cheers!!