How to mount a remote directory in Linux using SSHFS

Source: Internet
Author: User
Tags ftp file ssh account

Q. I have access rights to one of the remote server through SSH protocol and there are no File share services such as Samba, NFS or FTP etc which is enabled on the server. Now I want to mount data from this remote server, is it possible to mount remote folders?

A. the answer to this are yes, We can share data/mount folder on A Local machine by using just SSH protocol. This can is done by using the FUSE(Filesystem in use rspace) which supportSSH and FTP file Syste Ms. This post was in response to conversation which I had with one of our users. The question he asked about FTP was "I want to transfer one latest file from my FTP server and I want to automate this Task through shell script to download latest file from my FTP server, and I don ' t know what's the Operating System at Ser Ver End (This was ultimate sentence I hear from the user today in my office). Let's prepare our machine in how-to-mount a remote folder by using SSH protocol.

STEP1: Installing package

On Ubuntu/debain

Apt-get Install SSHFS

On Redhat/centos/fedora

RPM-IVH fuse-sshfs-1.8-1.el5.rf.i386.rpm

STEP2: Once the installed we have to create a mount point and mount our server data using SSHFS command, for which we Require Username/password. Here is my details for this task.

My username:rootmy password:redhatmy server:10.233.10.212my mount point:/mnt/ssh

Now create the mount point and Mount SSH account data.

#mkdir/MNT/SSH#SSHFS [email protected]://mnt/ssh/[email protected] ' s password:

STEP3: The above command would mount my root directory in 10.233.10.212 server. Testing our Setup

Check If you is able to see data

#cd/mnt/ssh

#ls

Sample output

Bin CDROM data etc initrd.img Lib media opt root selinux sys tmp var vmlinuz.oldboot c MDB-BKP Dev Home initrd.img.old lost+found mnt proc sbin srv test usr vmlinuz

What is about DF-HS command output?

Sample output

Filesystem Size used Avail use% mounted on
/dev/sda2 12G 8.4G 2.5G 78%/
/dev/sda6 80G 43G 34G 56%/var
/dev/sda5 2.0G 41M 1.8G 3%/Home
/DEV/SDA1 99M 12M 83M 12%/boot
Tmpfs 506M 0 506M 0%/dev/shm
Sshfs#[email protected]:/ 1000G 0 1000G 0%/mnt/ssh

STEP4: So why about mounting it permanently?. We can do it by editing Fstab file In/etc folder

#vi/etc/fstab

Go to last line and type below line

Sshfs#[email protected]://mnt/ssh Fuse defaults 0 0

Save the file and exit. Now run mount-a to update the Fstab file state to kernel.

Note: Its is advisable to the write passwords in human readable files Like/etc/fstab.

#mount-A

Let me explain-entry in fstab indicates. We are mentioning mount user root data which be located on 10.233.10.212 server on TO/MNT/SSH using fuse file system with Default settings.

STEP5: What's about unmounting this drive?

#umount/mnt/ssh

Enjoy new learning of mounting a folder using SSH protocol.

How to mount a remote directory in Linux using SSHFS

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.