How can I share files between two Linux machines over LAN?

72,753

Solution 1

In Nautilus, select File | Connect to Server ...

There are a lot of options to share a file-system over a network in unix/linux. Nautilus supports some of them: ssh, webdav, ftp, smb and others. Obviously, any of these solutions requires that the corresponding daemon is running on remote host.

NFS is unix native "standard" way to share a file-system in a lan but the time needed to configure and manage such a solution is not worth the result in a so simple network as yours. IMHO, ssh is the best solution in your environment.

Usually ssh is used to log on and to execute commands on a remote machine. The way you connect to the remote machine is not the way to share a file-system but the way to execute remote commands. If you want to mount a remote file system via ssh via command line, try something like: sshfs remoteusername@host:/home/remoteusername /home/localusername/somedir (or use nautilus wizard).

Solution 2

You can use the secure copy command if the main aim behind sharing the mount to point is to copy/ move files:

$ scp [email protected]:foobar.txt /some/local/directory

http://www.hypexr.org/linux_scp_help.php

Solution 3

I just wanted to comment that the easiest way to avoid the problem your having by only accessing the home folder of the user you log into is to log in as root as long as ssh.sshd_config file (in etc dir) is set up to allow this you will have access to your entire file system. Although if you do this i suggest also disabling password authentication and instead using SSH keys so that only the computer on your LAN will be able to use it. Predators will try to guess your password and can try hundreds or thousands in a matter of minutes no matter how strong your password is it can still be guessed... The key will make it so this is impossible. But your computer will be able to access all the files on the remote computer without a hitch. :)

Solution 4

if your machines are UNIX-base such as linux you can use NFS (Network File Sharing) protocol.This protocol has /etc/exports being places you define shared directory, and you can connect to server with mount -t nfs. For example:

/home/mohsen/diff  10.0.0.2(rw,sync,subtree_check) localhost(rw,sync,subtree_check)

Above line, define a directory in /etc/exports and share it between this computer and 10.0.0.2 and localhost as client for read and write.

NOTE: each line for one dir.

 mount -t nfs localhost:/home/mohsen/diff ./x

Solution 5

You can mount a SAMBA directory anywhere you want (with that you can access it via console or as a regular directory in nautilus).

# mount -t cifs //REMOTE_COMPUTER/Multimedia /mount/point -o guest

You need to install cifs-util.

Share:
72,753

Related videos on Youtube

Bryan Wolfford
Author by

Bryan Wolfford

Updated on September 18, 2022

Comments

  • Bryan Wolfford
    Bryan Wolfford over 1 year

    I am currently running Fedora 18 with Gnome on two computers which are connected to the same router. I have been using Samba to share files between the two, but I know there must be a better way.

    On the left panel in Nautilus, there is a menu for me to access my other computer's shared directories via Network -> Browse Network -> Windows Network -> Computer. What is the way to accomplish a similar way to access a shared directory between two Linux machines, without going through the "Windows Network"?

    Preliminary research suggests that using SSH to mount a remote directory may be what I'm looking for, but when I SSH into the other computer, I am left at the console scratching my head. If that is the correct method, I would greatly appreciate it if someone would offer some insight on how to accomplish the sharing.

  • Bryan Wolfford
    Bryan Wolfford about 11 years
    In my version of Gnome, Nautilus does not have any such menu... however via the console, typing 'nautilus-connect-server' brought up the menu, and I was able to connect via SSH that way, but that only gives access to the user-that-I-logged-in-as's home directory... how would I get a link like this that shows me other "shared" directories like I had in Samba? Thanks for pointing me in the correct direction!
  • serb
    serb about 11 years
    IIRC, in old versions of gnome Connect to Server ... was not in File menu but in Go or Edit.
  • serb
    serb about 11 years
    Perhaps, you have to install gvfs (gnome virtual file system) package.
  • Bryan Wolfford
    Bryan Wolfford about 11 years
    I think I have the most current version in Gnome 3, and there are no menus at all.
  • Matteo
    Matteo about 10 years
    A key can also be guessed as a password. In both cases it's the length that will determine how many tries are needed for a brute force attack.
  • Harvey
    Harvey over 9 years
    Who is correct here? Can a key be guessed, or is there some reason that outside access is impossible? There must be a way of keeping your lan protected from the outside, while freely sharing within the lan, right?
  • Aaron Smith
    Aaron Smith over 6 years
    Yes, there is. Matteo is correct though technically keys can be guessed as well, but it is highly unlikely that someone would spend the years it could take to brute force encryption of this nature. But to be on the safe side, you can also add the users you wish to be able to connect to you to your sshd.config file or use host keys as well so that only someone with a key from the host computer can connect. ssh is perfectly safe if you learn how to use it correctly. But nfs is also a valid option.