Securely share files between your computer and phone using samba


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.


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


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 Type following commands in a terminal.

sudo ufw allow from 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 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


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 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.

Screenshot from 2013-06-16 14:26:00


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.




Filed under Uncategorized

2 responses to “Securely share files between your computer and phone using samba

  1. johnfail

    For an extra layer of security (and assuming the Android app(s) you’re using support it) you can also switch to a different port rather than using 22:

    sudo ufw allow proto tcp from 192.168 .0.0/16 to any port 1234

    It might be overkill for your local network, though.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s