个人工具

UbuntuHelp:SSHFS

来自Ubuntu中文

Oneleaf讨论 | 贡献2007年5月13日 (日) 11:22的版本 (New page: {{From|https://help.ubuntu.com/community/SSHFS}} {{Languages|php5}} === Overview === Ssh is a secure protocol for communicating between machines. Sshfs is a tool ...)

(差异) ←上一版本 | 最后版本 (差异) | 下一版本→ (差异)
跳转至: 导航, 搜索

Overview

Ssh is a secure protocol for communicating between machines. Sshfs is a tool that uses ssh to enable mounting of a remote filesystem on a local machine; the network is (mostly) transparent to the user. Because ssh authenticates connections, you can be sure that only those who should have access to remote directories can mount them (as long as everything is configured properly). Because ssh encrypts connections, no one can see your files as they are transferred over the network.

Installation and Setup

Simply install the sshfs package. The dependencies should be automatically installed too.

sudo apt-get install sshfs
</code>

Then add yourself to the ''fuse'' group.  This is necessary so you can use the <code>fusermount</code> command, which is needed by the FUSE userland filesystem utility.  If you don't do this, you will get permission errors.  You must log out and log back in in order for the changes to take effect.
<pre>
sudo adduser $USER fuse
</code>

=== Usage ===

Now, assuming that you have an ssh server running on a remote machine, simply run the sshfs command to mount the remote directory.  In this example, the remote directory is <code>/projects</code> on remote host <code>far</code>.  The local mount point is ~/projects.
<pre>
sshfs $USER@far:/projects ~/projects
</code>

To unmount, 
<pre>
fusermount -u ~/projects
</code>

To add it to your <code>/etc/fstab</code>,
<pre>
sshfs#$USER@far:/projects    /home/$USER/remote    fuse    defaults    0 0
</code>
Note that you have to change ''$USER'' to your login name when editing <code>fstab</code>, but it is not necessary when typing commands (the shell does it for you in that case).

One thing to be aware of is that your UID (''User ID'', the unique number of your user on a system) is not necessarily the same on the two hosts.  When you <code>ls -l</code>, the user name associated with each file is printed in the third column.  However, in the filesystem, only UIDs are stored, and <code>ls</code> simply looks up the UID and finds the user name associated with it.  In Unix, UIDs are what matter, not the user names.  So if you're 1000 on the local host and 1003 on the remote host, the sshfs mounted directory would show a different user name for your files.  This is not a problem, though, because the ssh server on the remote machine is what is actually reading and writing files.  So even though it shows up in <code>ls -l</code> as a different UID, any changes will be done through the ssh server on the remote host, which will use the correct UID for the remote machine.  Problems may arise if you attempt to use a program that looks at UIDs of files (e.g. <code>ls</code> prints the wrong user name).

=== Links ===

* This page is based off of [http://ubuntu.wordpress.com/2005/10/28/how-to-mount-a-remote-ssh-filesystem-using-sshfs/ this] howto.

[[category:UbuntuHelp]]