24

Is there a way to mount a Linux directory from a different PC to your local Linux PC? How?

Emre Yazici
  • 10,136
  • 6
  • 48
  • 55
ksuralta
  • 16,276
  • 16
  • 38
  • 36

5 Answers5

39

sshfs is very nice, and easy to use

sshfs user@remotesystem:/remote/dir /some/local/dir
phuclv
  • 37,963
  • 15
  • 156
  • 475
Georg Zimmer
  • 899
  • 1
  • 7
  • 13
  • 2
    Much simpler solution, especially for quick tasks. Something not clearly documented: -o ro will mount the file system readonly. – Artem Russakovskii Sep 07 '15 at 22:09
  • 2
    Adding "-C" switch will enable compression and can greatly increase transfer speeds - in my case a 8 fold improvement. – Mtl Dev Dec 13 '16 at 15:53
  • If the SSH connection drops for any reason you may lose your data. Hence,you’d want to save your work regularly as you work on files within an SSHFS mount. – Hamedz Sep 27 '19 at 20:45
16

Yes, it's called NFS. You might also want to check out sshfs which is pretty nice.

Robert Gamble
  • 106,424
  • 25
  • 145
  • 137
12

You need to be a bit more specific. You can use NFS.

Depending on what distro you're using, you simply edit the /etc/exports file on the remote machine to export the directories you want, then start your NFS daemon.

Then on the local PC, you mount it using the following command:

mount -t nfs {remote_pc_address}:/remote/dir /some/local/dir

Use the man utility for more information:

man exports (Examples of configuring directories for export are on the bottom of this manual page.)

phuclv
  • 37,963
  • 15
  • 156
  • 475
  • 1
    Why do I need to "export" the directory from the remote machine? Why isn't `mount -t nfs {remote_pc_address}:/remote/dir /some/local/dir` from the local machine enough? – a06e May 05 '15 at 12:32
5

NFS is handy since it's built-in and easy to configure, but the 2 common implementations (NFSv2 and NFSv3) don't translate usernames between the systems; user IDs are used instead. This requires you to use a central auth system such as LDAP so tha tcommon user IDs can be maintained.

sshfs requires you to connect as a single user and so accesses are always done (and consequently, can only be done) as that user.

cifs in a *nix-to-*nix connection (via Samba) both translates usernames and follows standard *nix permissions. As well, it is more flexible in that it allows you to perform ownership/permission transformation on creation of a new file or directory. It is, however, much more complex to configure.

phuclv
  • 37,963
  • 15
  • 156
  • 475
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358
1

sshfs works pretty well for me.

sudo sshfs -o allow_other root@1.2.3.4:/directory local_directory

remote machine ip : 1.2.3.4

phuclv
  • 37,963
  • 15
  • 156
  • 475
akshaypmurgod
  • 77
  • 1
  • 3