Using sshfs
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.
- On computer A, which will be the server, make sure the sshd daemon is installed and running.
- 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
- If you do not see a rule like that, pick ONE of the following:
- 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:
- make a directory somewhere. Replace <your directory> with whatever you choose to name it
- Change the group ownership and permissions on this directory:
chgrp users <your directory>
- 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>
- On computer B, you need the sshfs package.
- Make a directory as the mount point
mkdir <new directory>
- 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
- directory mount point: on_the_server
- type in the password for the user.
su -c "service sshd status"This command should return something like
openssh-daemon (pid 1615) is running...
su -c "iptables -L | grep ssh"You should see something like the following:
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
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"
su -c "usermod -G -a <username> "
mkdir <your directory>
su -c "yum install sshfs"
sshfs -C testing@192.168.0.5:/var/www/html on_the_server
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:
- On the server computer, make sure the sshd daemon is running
- Make sure iptables has a rule to open up the ssh port. The default port is 22
- 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:
- On the server computer, check the owner and group membership on the directory
- Check the directory's permissions
- 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

