Personal tools
You are here: Home Team Members Charles Amey Using sshfs

Using sshfs

by Charles Amey last modified Jun 29, 2011 01:02 PM
— filed under:

Install sshfs on a computer to be able to mount up directories on a remote system via ssh

Applicable to Fedora versions

  • Fedora 12+

 Doing the work

You've got two computers, call them A and B.  A will be the "server", since it has directories that you want to be able to access from B.  You do not have to mount the shares - you can use gvfs or fish to connect via ssh to remote computers.  Mounting them could be a faster way of the machines live on the same network and don't get moved that often.  One could also set up a login script to connect to a bunch of network shares at once upon login.

 

  1. On computer A, which will be the server, make sure the sshd daemon is installed and running. 
  2. su -c "service sshd status"
    This command should return something like
    openssh-daemon (pid  1615) is running...
  3. Check to make sure iptables is letting port 22 through.  If you changed ssh to use another port other than the standard port, check for that port instead
  4. su -c "iptables -L | grep ssh"
    You should see something like the following:
    ACCEPT  tcp  -- anywhere  anywhere   state NEW tcp dpt:ssh
  5. If you do not see a rule like that,  pick ONE of the following:
  6. su -c "system-config-firewall"
    Put a check beside SSH OR
    su -c "iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT"
  7. If you are going to set up a directory for multiple people to have read and write access to, a good group membership would be "users".  Add the user to the users group:
  8. su -c "usermod -G -a <username> "
  9. make a directory somewhere.  Replace <your directory> with whatever you choose to name it
  10. mkdir <your directory>
  11. Change the group ownership and permissions on this directory:
    chgrp users <your directory>
  12. If you have more than one user putting things in here, and you want other people to also get those files,  set the sticky bit so that the group ownership of everything in this directory is owned by "users"
    chmod g+s <your directory>
  13. On computer B, you need the sshfs package.  
  14. su -c "yum install sshfs"
  15. Make a directory as the mount point
    mkdir <new directory>
  16. mount up a directory that lives on computer A to the new directory you created on computer B from the previous step.  The -C option is for compression, which generally speeds up data transfers between hosts.
    sshfs -C <username>@<ip address of computer A>:<directory on computer A>  <directory name from step8>
    An example, computer A information
    • ip address: 192.168.0.5
    • username: testing
    • directory to mount: /var/www/html
    Computer B information
    • directory mount point: on_the_server
    sshfs -C testing@192.168.0.5:/var/www/html  on_the_server
  17. type in the password for the user.

Troubleshooting

Common Problems and Fixes

You should be able to browse the mounted directory and see files.  If you cannot see anything, check the following:

  1. On the server computer, make sure the sshd daemon is running
  2. Make sure iptables has a rule to open up the ssh port.  The default port is 22
  3. Check the username and password on the server.  Make sure you can login with those credentials

Writing files to the share

 If you are having trouble writing files to the share, try the following:

  1. On the server computer, check the owner and group membership on the directory
  2. Check the directory's permissions
  3. Check the user account to make sure they are in the proper groups for that directory

Disclaimer

We test this stuff on our own machines, really we do. But you may run into problems, if you do, come to #fedora on irc.freenode.net

 

 

 

 

Document Actions
Log in


Forgot your password?
New user?