I want to share the folders between my laptop and local desktop. Both are connected to WiFi and ethernet respectively. How do I share the folders between these two?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.Sign up to join this community
If computers are connected to different networks, this can be achieved using Hamachi. It enables computers to see each other as if they were in the same network. It can be used with very nice front-end called Haguichi.
If your computers are connected to the same local network start from here.
Now you need to share files somehow. Fortunately, Ubuntu makes it really easy. Just right-click any directory and pick
Local Network Share.
Window like this one should pop up:
Then configure your share and click
On the other PC
Open Nautilus, click
Connect to Server on the left menu. Another dialog should pop up:
smb://[ip address of the other computer here] and click
If you use Hamachi, you will need to provide host's IP as seen by Hamachi. Either use
hamachi list command or right-click other computer in Haguichi and select
Copy IPv4 Address.
And that's it!
If you are capable to establish SSH connection between these two computers, you can use
sshfs to mount a remote folder (even entire filesystem, if you have right permissions).
sudo apt update && sudo apt install -y sshfs
For example, if you are using key authentication, the mounting command looks like:
sshfs username@hostname_or_ip:/path/to/remote-folder/ /path/to/local-folder/ -p 2222 -o IdentityFile=/path/to/ssh-key/id_rsa
-p 2222you can omit this option, if you are using the default ssh port
-o IdentityFile=/path/to/ssh-key/id_rsayou can omit this option, if yours key is placed in the default location (
~/.ssh), or if you using
username@hostname_or_ipyou can replace this entry with its equivalent short name, if you using
sudo umount /path/to/local-folder/to unmount;
sshfs -hor its man page.
So, if the
~/.ssh/config file looks like:
Host rh1 HostName 126.96.36.199 IdentityFile ~/.ssh/remote-host-1/id_rsa User spas Port 22 Host rh2 HostName 188.8.131.52 IdentityFile ~/.ssh/remote-host-2/id_rsa User spas Port 2222
The mounting command will looks more simple:
$ sshfs rh1:/path/to/remote-folder/ /path/to/local-folder/
sshfs mounting works, you can:
My preferred method is to use an online sync with a local client, which has the additional benefit of storing your data in the cloud. This is useful for instance if you have a PC at home and one at work/study, or in the extreme case that both of your computers fail.
To share folders
Install the client in both computers (see links above). Both create a menu entry. (Dropbox seems to have a bug relating its icon. See this answer to fix).
Open the client in the computer which has the original folder and then create the sync. For example, in Megasync, right-click on the panel icon and select settings. Then, go to Sync tab, and select Add. Choose the local folder to share, and create a folder in your cloud. You should get something like this:
When you press OK, the files will start to be uploaded to Mega. The process is more or less similar with Dropbox. More details at the bottom of the post.
That's it. Your two folders are in sync and secure in the cloud.
As I said, there are many sync clients. I prefer Mega because:
~/Music); Dropbox sync only the content inside a "Dropbox" folder (e.g.
~/Dropbox/Music), which is annoying.
~/.q3a); Dropbox only allows for stuff inside the same "Dropbox" folder.
The only problem I see is that Mega can go bust at any time (because of copyright issues). It happened to Megaupload before. Dropbox might me more secure.