“UbuntuHelp:SSHFS”的版本间的差异
来自Ubuntu中文
小 |
小 |
||
第2行: | 第2行: | ||
{{Languages|UbuntuHelp:SSHFS}} | {{Languages|UbuntuHelp:SSHFS}} | ||
=== Overview === | === Overview === | ||
− | [[UbuntuHelp: | + | [[UbuntuHelp:SSHHowto|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 === | === Installation and Setup === | ||
Simply install the sshfs package. The dependencies should be automatically installed too. | Simply install the sshfs package. The dependencies should be automatically installed too. | ||
第8行: | 第8行: | ||
sudo apt-get install sshfs | sudo apt-get install sshfs | ||
</nowiki></pre> | </nowiki></pre> | ||
− | Then add yourself to the ''fuse'' group. This is necessary so you can use the <code><nowiki>fusermount</nowiki></code> command, which is needed by the FUSE userland filesystem utility. If you don't do this, you will get permission errors. | + | Then add yourself to the ''fuse'' group. This is necessary so you can use the <code><nowiki>fusermount</nowiki></code> command, which is needed by the FUSE userland filesystem utility. If you don't do this, you will get permission errors. |
<pre><nowiki> | <pre><nowiki> | ||
sudo adduser $USER fuse | sudo adduser $USER fuse | ||
</nowiki></pre> | </nowiki></pre> | ||
+ | You must log out and log back in in order for the changes to take effect, or try: | ||
+ | <pre><nowiki> | ||
+ | su user | ||
+ | </nowiki></pre> | ||
+ | where user is your current user name at the command prompt. | ||
=== Usage === | === 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><nowiki>/projects</nowiki></code> on remote host <code><nowiki>far</nowiki></code>. The local mount point is ~/projects. | 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><nowiki>/projects</nowiki></code> on remote host <code><nowiki>far</nowiki></code>. The local mount point is ~/projects. | ||
第27行: | 第32行: | ||
Note that you have to change ''$USER'' to your login name when editing <code><nowiki>fstab</nowiki></code>, but it is not necessary when typing commands (the shell does it for you in that case). | Note that you have to change ''$USER'' to your login name when editing <code><nowiki>fstab</nowiki></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><nowiki>ls -l</nowiki></code>, the user name associated with each file is printed in the third column. However, in the filesystem, only UIDs are stored, and <code><nowiki>ls</nowiki></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><nowiki>ls -l</nowiki></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><nowiki>ls</nowiki></code> prints the wrong user name). | 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><nowiki>ls -l</nowiki></code>, the user name associated with each file is printed in the third column. However, in the filesystem, only UIDs are stored, and <code><nowiki>ls</nowiki></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><nowiki>ls -l</nowiki></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><nowiki>ls</nowiki></code> prints the wrong user name). | ||
+ | === GUI (Graphical User Interface) for SSHFS === | ||
+ | A GUI program to create and manage SSHFS connections is available [http://dev.wa2.nl/sshfsgui/ here]. | ||
=== Keep Alive === | === Keep Alive === | ||
− | Your ssh session will automatically log out if it is idle. To keep the connection active (alive) add this to '''/etc/ssh/ssh_config''' on the client. | + | Your ssh session will automatically log out if it is idle. To keep the connection active (alive) add this to '''~/.ssh/config''' or to '''/etc/ssh/ssh_config''' on the client. |
<code><nowiki>ServerAliveInterval 5</nowiki></code> | <code><nowiki>ServerAliveInterval 5</nowiki></code> | ||
This will send a "keep alive" signal to the server every 5 seconds. You can usually increase this interval, and I use 120. | This will send a "keep alive" signal to the server every 5 seconds. You can usually increase this interval, and I use 120. |
2008年10月19日 (日) 17:23的版本
点击翻译: |
English |
请不要直接编辑翻译本页,本页将定期与来源同步。 |
目录
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
Then add yourself to the fuse group. This is necessary so you can use the fusermount
command, which is needed by the FUSE userland filesystem utility. If you don't do this, you will get permission errors.
sudo adduser $USER fuse
You must log out and log back in in order for the changes to take effect, or try:
su user
where user is your current user name at the command prompt.
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 /projects
on remote host far
. The local mount point is ~/projects.
sshfs $USER@far:/projects ~/projects
To unmount,
fusermount -u ~/projects
To add it to your /etc/fstab
,
sshfs#$USER@far:/projects /home/$USER/remote fuse defaults 0 0
Note that you have to change $USER to your login name when editing fstab
, 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 ls -l
, the user name associated with each file is printed in the third column. However, in the filesystem, only UIDs are stored, and ls
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 ls -l
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. ls
prints the wrong user name).
GUI (Graphical User Interface) for SSHFS
A GUI program to create and manage SSHFS connections is available here.
Keep Alive
Your ssh session will automatically log out if it is idle. To keep the connection active (alive) add this to ~/.ssh/config or to /etc/ssh/ssh_config on the client.
ServerAliveInterval 5
This will send a "keep alive" signal to the server every 5 seconds. You can usually increase this interval, and I use 120.
Links
- This page is based off of this howto.