Linux mount remote linux share

Best way to mount remote folder

I have two RasberryPi running debian wheezy and I would like to mount a folder from computer A on computer B. What is the best (as in most efficient) way to do this? I can do it via SMB, but that is for windows, I think there must be a better way to share across linux.

4 Answers 4

SSHFS is wonderful. It can mount remote directories in a local directory with FUSE. The commands below use # to indicate that a command was executed as root , while $ indicates execution as a regular user. Because FUSE software is required, first make sure that it is available and running.

One of the lsmod and grep commands, below, can reveal if the software is loaded and ready for use. A result from either command indicates that fuse is available.

# lsmod | grep fuse $ grep -i fuse /lib/modules/$(uname -r)/modules.builtin 

If there is no result from either command, try to load the kernel module without a reboot using modprobe and check again.

# modprobe fuse # lsmod fuse 

If loading the module fails, install the software with apt-get .

Check again after installation.

# modprobe fuse # lsmod fuse 

FUSE must be installed and running before continuing.

Check the permissions of /dev/fuse . The permissions should provide your regular user account with read and write access. Skip this part if you have determined that your regular user account already has read and write permission on /dev/fuse .

The output might be something like one of the following.

crw-rw-rw- 1 root root (all users can read/write) crw------- 1 root fuse (only root can read/write) crw-rw---- 1 root fuse (root and members of fuse group can read/write) 

In 2013, my Debian created /dev/fuse with 0600 permissions, owner root , group owner fuse . I needed to let the fuse group use the device and to add my regular user account to the group, as shown below.

# usermod -aG fuse $your_regular_user_account # chmod 0660 /dev/fuse 

If the new group membership was required, log out and in again to become a member of the group.

Next, install ssh on both sides as follows.

This answer was written for Debian, but on Ubuntu 18.x at least, openssh-client , fuse , and a few other packages are a part of the Ubuntu sshfs package. The sshfs software is required on the client side, but it can be installed on both sides if desired. One of the package dependencies is fuse , but the installer skips over software that has already been installed.

# Ubuntu 18.x: # apt-get install sshfs 

With fuse and ssh available, and with permission to use the device, /dev/fuse , create a mount point for the remote file system; and, mount that remote filesystem locally as follows.

# mkdir /mnt/$directory_name # chown $your_user:$group /mnt/$directory_name/ $ sshfs $remote_username@$remote_server_name: /mnt/$directory_name/ 

To mount a directory other than home, specify it after the colon.

$ sshfs $remote_username@$remote_server_name:/remote/directory /mnt/$directory_name 

To unmount, use fusermount .

fusermount -u /mnt/$directory_name 

If you have a Windows machine, it too can use SSHFS with win-sshfs. This software will «map a drive» with SSHFS, so that you can have a Windows drive letter that contains the remote directory.

Читайте также:  What is file server in linux

You can significantly improve the performance speed of SSHFS by using additional options. See this article for more info and speed comparisons with NFS: admin-magazine.com/HPC/Articles/Sharing-Data-with-SSHFS

Hey — I tried to use your instructions (adjusting to yum install fuse-sshfs.x86_64 ) but when I did modprobe fuse it didn’t create a fuse group for me. So when I did usermod -a -G fuse [your-user] , I got usermod: group ‘fuse’ does not exist . can you assist ? thanks in advance

lsmod | grep fuse does return result and I do have /dev/fuse ,m which is owned by root. so you’re saying i’m okay without the group ?

After # apt-get install fuse-utils sshfs I get «Unable to locate package fuse-utils». Any idea why? (Ubuntu 18.04.01)

You can use plenty of things, among which, popular options are:

By ease-of-setup I think they would have to be put in this order (top: easiest)

Through FUSE, you can mount remote filesystems via ssh. I won’t cover how, as Cristopher has already very well explained that. Just note that, in order to mount the file automatically it will need a bit more of work.

It will allow you to use Windows and Unix machines to access the remote folder. If it’s not a big deal for you, then you won’t probably benefit from it. However, it’s easy to automount it on init (just input the apropriate values at /etc/fstab , including username=,password= in the options column.

It will let you authenticate just via IP (no usernames thing = faster, only of use inside your non-hostile LAN) or via Kerberos Tickets (too painful for just two Raspberries; but useful in corporate environments).

As it has kernel mode support, it will run faster than sshfs. Besides, as there’s no encryption performed it will have a better throughput, and in the case of the tiny Raspberry ARM, it may make a difference.

Besides, it’s not so painful to setup simply you trust your network. You have automount support in /etc/fstab too, and you don’t have to put sensitive data (such as usernames or passwords), and if you have your usernames syncrhronized (same /etc/passwd and /etc/group files) you can use the usual POSIX permissions toolset ( chown , chgrp and chmod ).

Источник

dublado / sshfs.md

SSHFS stands for (Secure SHell FileSystem) client that enable us to mount remote filesystem and interact with remote directories and files on a local machine using SSH File Transfer Protocol (SFTP).

SFTP is a secure file transfer protocol that provides file access, file transfer and file management features over Secure Shell protocol. Because SSH uses encryption while transferring files over the network from one computer to another computer and SSHFS comes with built-in FUSE (Filesystem in Userspace) kernel module that allows any non-privileged users to create their file system without modifying kernel code.

Читайте также:  Gvfs smb linux mint

In this article, we will show you how to install and use SSHFS client on any Linux distribution to mount remote Linux filesystem or directory on a local Linux machine.

Step 1: Install SSHFS Client in Linux Systems

By default sshfs packages does not exists on all major Linux distributions, you need to enable epel repository under your Linux systems to install sshfs with the help of Yum command with their dependencies.

# yum install sshfs # dnf install sshfs [On Fedora 22+ releases] $ sudo apt-get install sshfs [On Debian/Ubuntu based systems]

Step 2: Creating SSHFS Mount Directory

Once the sshfs package installed, you need to create a mount point directory where you will mount your remote file system. For example, we have created mount directory under /mnt/tecmint.

# mkdir /mnt/tecmint $ sudo mkdir /mnt/tecmint [On Debian/Ubuntu based systems]

Step 3: Mounting Remote Filesystem with SSHFS

Once you have created your mount point directory, now run the following command as a root user to mount remote file system under /mnt/tecmint. In your case the mount directory would be anything.

The following command will mount remote directory called /home/tecmint under /mnt/tecmint in local system. (Don’t forget replace x.x.x.x with your IP Address and mount point).

# sshfs tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint $ sudo sshfs -o allow_other tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint [On Debian/Ubuntu based systems]

If your Linux server is configured with SSH key based authorization, then you will need to specify the path to your public keys as shown in the following command.

# sshfs -o IdentityFile=~/.ssh/id_rsa tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint $ sudo sshfs -o allow_other,IdentityFile=~/.ssh/id_rsa tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint [On Debian/Ubuntu based systems]

Step 4: Verifying Remote Filesystem is Mounted

If you have run the above command successfully without any errors, you will see the list of remote files and directories mounted under /mnt/tecmint.

[root@ tecmint]# ls 12345.jpg ffmpeg-php-0.6.0.tbz2 Linux news-closeup.xsl s3.jpg cmslogs gmd-latest.sql.tar.bz2 Malware newsletter1.html sshdallow epel-release-6-5.noarch.rpm json-1.2.1 movies_list.php pollbeta.sql ffmpeg-php-0.6.0 json-1.2.1.tgz my_next_artical_v2.php pollbeta.tar.bz2

Step 5: Checking Mount Point with df -hT Command

If you run df -hT command you will see the remote file system mount point.

Filesystem Type Size Used Avail Use% Mounted on udev devtmpfs 730M 0 730M 0% /dev tmpfs tmpfs 150M 4.9M 145M 4% /run /dev/sda1 ext4 31G 5.5G 24G 19% / tmpfs tmpfs 749M 216K 748M 1% /dev/shm tmpfs tmpfs 5.0M 4.0K 5.0M 1% /run/lock tmpfs tmpfs 749M 0 749M 0% /sys/fs/cgroup tmpfs tmpfs 150M 44K 150M 1% /run/user/1000 tecmint@192.168.0.102:/home/tecmint fuse.sshfs 324G 55G 253G 18% /mnt/tecmint

Step 6: Mounting Remote Filesystem Permanently

To mount remote filesystem permanently, you need to edit the file called /etc/fstab. To do, open the file with your favorite editor.

# vi /etc/fstab $ sudo vi /etc/fstab [On Debian/Ubuntu based systems]

Go to the bottom of the file and add the following line to it and save the file and exit. The below entry mount remote server file system with default settings.

sshfs#tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint fuse.sshfs defaults 0 0

Make sure you’ve SSH Passwordless Login in place between servers to auto mount filesystem during system reboots..

Читайте также:  Linux mount windows dfs

If your server is configured with SSH key based authorization, then add this line:

sshfs#tecmint@x.x.x.x:/home/tecmint/ /mnt/tecmint fuse.sshfs IdentityFile=~/.ssh/id_rsa defaults 0 0

Next, you need to update the fstab file to reflect the changes.

# mount -a $ sudo mount -a [On Debian/Ubuntu based systems]

Step 7: Unmounting Remote Filesystem

To unmount remote filesystem, jun issue the following command it will unmount the remote file system.

That’s all for now, if you’re facing any difficulties or need any help in mounting remote file system, please contact us via comments and if you feel this article is much useful then share it with your friends.

Источник

How to Mount a Linux directory from a different PC to your local Linux PC?

Much simpler solution, especially for quick tasks. Something not clearly documented: -o ro will mount the file system readonly.

Adding «-C» switch will enable compression and can greatly increase transfer speeds — in my case a 8 fold improvement.

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.

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

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

Why do I need to «export» the directory from the remote machine? Why isn’t mount -t nfs :/remote/dir /some/local/dir from the local machine enough?

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.

Источник

Оцените статью
Adblock
detector