In my home I have three computers running Ubuntu connected to a router, which form a network. It’s useful to be able to share files with my brother’s PC, and Ubuntu uses Samba as a solution for file sharing because Samba can easily share files with Microsoft Windows. However, in my experience Samba often doesn’t work as it should. When I want to access a Samba share on a remote PC it often starts whining about permissions and refuses access. I don’t know where to start to figure out a solution for this. And in principle, why should you use Samba which reverse-engineered the Microsoft SMB protocol? Shouldn’t there be a better solution which works flawlessly? I started looking around for other methods for easy file sharing, and I found OpenSSH. Using it is surprisingly easy, and you can share files fast and flawless. So that’s why I’m posting a guide to give easy instructions on how to use OpenSSH in combination with GNOME for file sharing.
Because the username and password of your system are used to log in to a computer with SSH, anyone who will be able to log in will have all the privileges that user has, like becoming root. I chose to create a new user account on my system so that I could use that user instead of my own user to log in with SSH, while also stripping this user of any privileges. Then I changed permissions of my home directory to allow read-only access to Others. This can be done by opening System → Administration → Users and Groups. Enter the details for the account, and then disable all the privileges. Now open your /home directory in the Nautilus file manager. Right click your home directory, go to Properties, go to Permissions and set Folder access for Others to Access files. Of course you should solve this differently if your home directory contains privacy sensitive information. Possibly a better solution would be to keep read access to your home directory disabled, while you use the home directory of the new user for writing files. You also place links (create a link to a directory by right clicking the directory and choosing Make Link) to a few directories inside your home directory which contain the files you want to share and for which you have enabled read access for Others.
To log in to a computer with SSH, you need to install the OpenSSH server package first. You can do this by opening Applications → Accessories → Terminal and then enter sudo apt-get install openssh-server there. Then you need to look up the IP-address of the computer you want to log in to, which you can do by opening System → Administration → Network Tools. In my case, I chose to select the Ethernet Interface (eth0) as the network device here. Then you can see the IPv4 IP address, which is what we need. Now use another computer in your home network, and open Places → Connect to Server… and select SSH as the Service type. In the Server field, fill in the IP address of the other computer. Leave the Port field blank, in the Folder field enter the path to your home directory (e.g. /home/alexander) and in the User name field enter the user name you use to log in to the computer. Enable the option to add a bookmark, and give it a name. The bookmark will appear in the Places menu, and in the Nautilus file manager. Then press Connect. You will then be notified that the identity of the computer you are connecting to is unknown, but you should ignore the message and connect anyway. Now you enter your password for the username you entered previously. You have options to forget or remember the password, I chose to remember the password. Now Nautilus will open and display the home directory of your computer. You can start sharing files now. For me this works a lot better than Samba, even though it’s still not the best solution for simple file sharing. This was merely a quick guide, and more detailed documentation is available here on Ubuntu’s documentation website.