Jump to content


 


Register a free account to unlock additional features at BleepingComputer.com
Welcome to BleepingComputer, a free community where people like yourself come together to discuss and learn how to use their computers. Using the site is easy and fun. As a guest, you can browse and view the various discussions in the forums, but can not create a new topic or reply to an existing one unless you are logged in. Other benefits of registering an account are subscribing to topics and forums, creating a blog, and having no ads shown anywhere on the site.


Click here to Register a free account now! or read our Welcome Guide to learn how to use this site.

Photo
- - - - -

Mount a remote directory over a local network using sshfs


  • Please log in to reply
1 reply to this topic

#1 Al1000

Al1000

  • Global Moderator
  • 5,997 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Scotland
  • Local time:09:30 AM

Posted 08 November 2016 - 03:42 PM

Mount a remote directory over a local network using sshfs

Guide Overview

The purpose of this guide is to teach you how to mount a remote directory over a local network using sshfs. This is an easy way to share files between Linux computers over a local network particularly when they are owned by the same user, as no root permissions are required, which is the case for the purpose of this guide.

Tools Needed
  • Two Linux computers and a router.
Instructions
  • Install sshfs (unless it is already installed) on both machines. In Debian-based distros, run this command in a terminal:
    apt-cache policy sshfs
    That will tell you whether it's already installed on your system and if it's available for installation. If it's not installed, but is available, install it by running this command in a terminal:
    sudo apt-get install sshfs
  • If either computer uses a firewall, create an exception for ssh. In Debian'based systems that use ufw, you can create an exception by running this command in a terminal:
    sudo ufw allow ssh
    If both computers use a firewall, be sure to do the same on each one.
  • Now create a mount point in your user's home directory. (A mount point is a directory for mounting a file system in). While file systems on other devices are ordinarily mounted in /media or /mnt, you can mount them anywhere.
    To create a mount point in your user's home directory called "mountp", open a terminal in your user's home directory and run this command:
    mkdir mountp
  • You can mount any directory that you are the owner of, without using root permissions, but for the purpose of this guide I'll mount my user's home directory from the remote system.
    To mount your user's home directory from the remote system, run this command in a terminal (from your user's home directory, where you created the mountpoint), swapping "yourusername" for your user name, and "remotesystemname" for the name of the remote system. This information is available from the command prompt in a terminal; the text preceding @ is your username, and the text following @ is the name of your system. For example, the command prompt on my remote system reads al@puppy-pc:~$ so my username is al and the name of the system is puppy-pc.
    sshfs yourusername@remotesystemname:/home/yourusername mountp
    So I would type:
    sshfs al@puppy-pc:/home/al mountp
  • Enter your password for the remote computer at the prompt.
    If you are not asked for your password, please see post #2 for another method.
  • Your user's home directory from the remote computer, should now be mounted in mountp.
    You can now open mountp in your file manager, and drag and drop files to and from your user's home directory on your remote computer, as if it was a directory on the computer you are using. :)
  • To unmount the remote directory, open a terminal in your user's home directory and run this command:
    fusermount -u mountp
That's all there is to it. You can either delete the directory mountp when you're finished, or leave it there for next time. :)

BC AdBot (Login to Remove)

 


m

#2 Al1000

Al1000
  • Topic Starter

  • Global Moderator
  • 5,997 posts
  • OFFLINE
  •  
  • Gender:Male
  • Location:Scotland
  • Local time:09:30 AM

Posted 08 November 2016 - 03:49 PM

If using the name of the remote computer in step 4 above doesn't work, try using its IP address instead. To find the IP address of the remote computer, open a terminal on it and run this command:
ifconfig
This will list all network devices on the computer, for example wifi and ethernet. You will find the IP address for the system in the information on the network device that is being used. It will read something like: inet addr:192.168.1.60

Modify the command in step 4 above to swap yourusername@remotesystemname, for the IP address of the remote system. For example if my remote system used the IP address above, I would type:
sshfs 192.168.1.60:/home/al mountp

Edited by Al1000, 08 November 2016 - 03:49 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users