Access to other Ubuntu machines in the LAN, jumping between different machines, is a hassle, if you can map the remote directory to the local will undoubtedly be used greatly, just like the network map disk under Windows. In the world of Linux there will undoubtedly be this mechanism and the way, recently in the process of using the SSHFS this tool to achieve the remote directory mapping to local functions.
SSHFS can gain all the encrypted communication benefits via SSH in a locally installed file system. Using SSHFS can map remote directory directly to the local, without modifying the remote machine settings, only require the SSH connection permissions (SSH is not, what can you do?)
Website address: http://fuse.sourceforge.net/sshfs.html
one, SSHFS for Ubuntu
Let's start with a brief introduction to SSHF.
About SSH introduction and installation use can refer to: SSH introduction and working mechanism as well as the Ubuntu environment in the installation and use of SSH in these two articles.
SSH is a powerful and secure tool, we can use it in addition to remote management of the host, but also through it to establish SSH tunnel for proxy, remote transfer files and so on. And here I want to introduce another feature, that is, the combination of SSHFS this tool can map the remote host file system to the local host, through SSH to the remote file system to mount to the computer, so that we can not use the SCP tool can be used to directly copy and delete the remote host files, It's as easy as working on a local disk.
SSH is a trusted way to connect two independent computers for remote control tasks.
The best thing about SSHFS is that you can get all the encrypted communication benefits through SSH in a locally installed file system. SSHFS is a FUSE-based SSH file system client program that can be used to mount remote file systems through the SSH protocol without any changes to the remote host configuration, which is very convenient and secure.
Second, install SSHFS on Ubuntu
The Ubuntu source already contains the SSHFS, as well as the required fuse packs, which can be installed directly:
[HTML]View PlainCopy
- sudo apt-get install SSHFS
The user group fuse is created automatically when installing, and users who want to use SSHFS need to add to this user group first (remember to log in again after completion), otherwise they will not have permission to execute Fusermount:
Fuse:failed to exec Fusermount:permission denied
Third, Mount remote file System/directory
The general format for mounting is:
[HTML]View PlainCopy
- sudo sshfs {{user id}}@{{server Hostname}}:{{desiredremote share}} {{desired local mount point}}-o idmap=user-o Allow_other -ouid={{local User ID}}-o gid={{local Group ID}}
Among the key options:
-O Transform_symlinks represents the conversion of absolute link symbols to relative link symbols
-O follow_symlinks Follow the link symbols on the server
-C compression, or-O Compression=yes
-O Reconnect automatic re-connection
-O Cache=yes
-O Allow_other
The mount format looks more dizzy, here combined with my use gives a concise and intuitive format:
[HTML]View PlainCopy
- Sshfs-o transform_symlinks-ofollow_symlinks [email protected]: [Dir]mountpoint
Examples are as follows:
[HTML]View PlainCopy
- Sshfs–o cache=yes,allow_other [email protected]:/home/user/code home/user/code
Description
1, the connection may require administrator rights, in the Mount command before Sudo can.
2, more parameters please man SSHFS, if you encounter other problems, please refer to the official FAQ.
3, if you want to not enter the password, you can use the SSH key authentication method.
4. After executing the command, Ubuntu will automatically display the mounted SSHFS file system disk on the desktop, and now you can manipulate the mapped disk as if it were a local disk.
Iv. Unloading
Fusemount–u/home/user/code
v. SSHFS Options
[HTML]View PlainCopy
- General Options:
- -O opt,[opt ...] Mount Options
- -H--help Print help
- -V--version print version
- SSHFS options:
- -p port equivalent to '-O port=Port '
- -c equivalent to ' -o compression=yes ' #启用压缩, recommended with
- -F ssh_configfile Specifies alternative ssh configuration file #使用非默认的ssh配置文件
- -1 equivalent to '-O ssh_protocol=1 ' #不要用啊
- -O Reconnect reconnect to server #自动重连
- -O delay_connect delay connection to server
- -O Sshfs_sync Synchronous writes
- -O no_readahead Synchronous reads (no speculative readahead) #提前预读
- -O sshfs_debug Print Some debugging information
- -o cache=BOOL enable caching {Yes,no} (default:yes) #能缓存目录结构之类的信息
- -o cache_timeout=N sets timeout for caches in seconds (default:20)
- -O cache_x_timeout=N sets timeout for {stat,dir,link} cache
- -O workaround=list Colon separated list of workarounds
- None Workarounds Enabled
- All workarounds Enabled
- [No]rename fix renaming to existing file (Default:off)
- [No]nodelaysrv set Nodelay TCP flag in sshd (Default:off)
- [No]truncate fix truncate for old servers (Default:off)
- [no]buflimit Fix buffer FillUp bug in Server (Default:on)
- -o idmap=TYPE user/group ID mapping, possible types is: #文件权限uid/gid mapping Relationship
- None translation of the ID space (default)
- User only translate UID of connecting user
- -O ssh_command=cmd execute cmd instead of ' ssh '
- -o ssh_protocol=N SSH protocol to use (Default:2) #肯定要2的
- -o sftp_server=SERV path to SFTP server or subsystem (DEFAULT:SFTP)
- -O directport=port directly connect to port bypassing SSH
- -O transform_symlinks transform absolute symlinks to relative
- -O follow_symlinks follow symlinks on the server
- -O no_check_root don ' t check for existence of ' dir ' on server
- -O password_stdin read password from stdin (only for Pam_mount)
- -o sshopt=VAL ssh options (see Mans Ssh_config)
- Module options:
- [SubDir]
- -o subdir=DIR prepend This directory to all paths (mandatory)
- -O [no]rellinks transform absolute symlinks to relative
- [Iconv]
- #字符集转换, for my kind of UTF8, the default is already the best
- -o from_code=CHARSET Original encoding of file names (default:utf-8)
- -o to_code=CHARSET New encoding of the file names (default:utf-8)
Vi. Summary: In the Ubuntu environment, direct access to other computer files on the network due to permissions problems, there will be a lot of problems; Recently, especially highlighted is the remote computer and local file comparison, folder comparison, can not use tools, extremely inconvenient. Using SSHSF to attach a folder on a remote computer to a local location, you can easily access remote files and compare remote files/folders to local files/folders using the Diff tool. such as using
Beyond CompareYou cannot compare remote files, folders, and local. This problem is resolved after mounting the remote folder. http://blog.csdn.net/netwalk/article/details/12952719
Use SSHFS to mount remote directories locally (as with Windows mount disks) under Ubuntu