Centos install sshfs to achieve mount directory

SSH is a powerful and secure tool. In addition to using it to remotely manage hosts, we can also use it to establish an SSH tunnel as a proxy, remotely transfer files, and so on. And here I want to introduce another function, which is to combine the sshfs tool to map the file system of the remote host to the local host, and mount the remote file system to the local host through SSH, so that we don’t need to use the scp tool You can copy and delete files on the remote host directly, just as convenient as operating a local disk.

The most dazzling part of SSHFS is that it can be installed locally in the file system, through SSH to obtain all the advantages of encrypted communication. sshfs is an SSH file system client program based on FUSE. With it, the remote host configuration can be mounted via the SSH protocol without any changes, which is very convenient and safe.

Github address: https://github.com/libfuse/sshfs


1. Install EPEL extension source

[ root@tokyo /]# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/centos/7/extras/x86_64/Packages/epel-release-7-9.noarch.rpm

2. Clean up YUM cache

[ root@tokyo /]# yum clean all

3. Use YUM to install SSHFS

[ root@tokyo /]#  yum install fuse-sshfs 

Four, mount remote directory

  1. Mount the /data/tmp directory on the server 8.8.8.8 to the /tmp directory of the machine, use -o to specify the parameter, port=ssh port number.
[ root@tokyo /]#  sshfs -o port=2200 [email protected]:/data/tmp /tmp
[email protected]'s password:
  1. View mounting results
[ root@tokyo /]# df -h  
Filesystem                        Size  Used Avail Use% Mounted on
devtmpfs                          993M     0  993M   0%/dev
tmpfs                            1000M     0 1000M   0%/dev/shm
tmpfs                            1000M  8.5M  991M   1%/run
tmpfs                            1000M     0 1000M   0%/sys/fs/cgroup
/dev/sda1                          30G  6.2G   22G  23% /
tmpfs                             200M     0  200M   0%/run/user/0
[email protected]:/data/tmp   30G  5.6G   23G  20%/tmp

Five, uninstall the remote directory
The unloading method is the same as the mount method, which uses umount. (The information I found is useful to fusermount -u mount_point)

[ root@tokyo /]#  umount /tmp 

Six, SSHFS options

general options:-o opt,[opt...]        mount options  
 - h   --help            print help  
 - V   --version         print version  
  
SSHFS options:-p PORT                equivalent to '-o port=PORT'   #Specify the ssh connection port
 - C                     equivalent to '-o compression=yes' #Enable compression,It is recommended to match
 - F ssh_configfile      specifies alternative ssh configuration file #Use a non-default ssh configuration file
 - 1      equivalent to '-o ssh_protocol=1' #Not recommended
 - o reconnect           reconnect to server               #Auto reconnect
 - o delay_connect       delay connection to server  
 - o sshfs_sync          synchronous writes  
 - o no_readahead        synchronous reads(no speculative readahead) #Read ahead
 - o sshfs_debug         print some debugging information  
 - o cache=BOOL          enable caching {yes,no}(default: yes) #Can cache information such as directory structure
 - o cache_timeout=N     sets timeout for caches inseconds(default:20)-o cache_X_timeout=N   sets timeout for{stat,dir,link} cache  
 - o workaround=LIST     colon separated list of workarounds  
    none             no workarounds enabled  
    all              all workarounds enabled  
    [ no]rename       fix renaming to existing file(default: off)[no]nodelaysrv   set nodelay tcp flag insshd(default: off)[no]truncate     fix truncate for old servers(default: off)[no]buflimit     fix buffer fillup bug inserver(default: on)-o idmap=TYPE          user/group ID mapping, possible types are:  #File permission uid/gid mapping
    none             no 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) #Definitely 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 fromstdin(only for pam_mount)-o SSHOPT=VAL          ssh options(see man ssh_config)  
  
Module options:[subdir]-o subdir=DIR       prepend this directory to all paths(mandatory)-o [no]rellinks     transform absolute symlinks to relative  
  
[ iconv]  
 # Character set conversion,UTF8 control for me,The default is already the best
 - o from_code=CHARSET   original encoding of file names(default: UTF-8)-o to_code=CHARSET      newencodingof the file names(default: UTF-8)

Recommended Posts

Centos install sshfs to achieve mount directory
How to install php7.3 in centos8 custom directory
Centos7.6 method to install Tomcat-8.5.39
How to install jdk1.8 on centOS7
How to install MySQL on CentOS 8
How to install R on CentOS 8
How to install FFmpeg on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
[Introduction to redis] Install redis under Centos
How to install TeamViewer on CentOS 8
How to install PHP7.4 in CentOS
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Jenkins on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Webmin on CentOS 8
How to install Ruby on CentOS 8
How to install Skype on CentOS 8
How to install htop on CentOS 8
How to install Python on CentOS 8
How to install Elasticsearch on CentOS 8
How to install HDP2.6 in Centos7.2
How to install Postgresql on CentOS 8
How to install Wordpress on Centos
How to install htop on CentOS 8
centos7 .*tar package to install MySQL5.7
How to install TeamViewer on CentOS 8
How to install MariaDB on CentOS 8
How to install MongoDB on CentOS 7
How to install Odoo 13 on CentOS 8
How to install Apache on CentOS 8
How to install OpenCV on CentOS 8
CentOS 6.8 method steps to install vsftpd
How to install PHP on CentOS 8
Use VMware15 to install Linux (CentOS6.5)
How to install MongoDB on CentOS 8
1.5 Install Centos7
How to install Android SDK in centos7
Graphic KVM to install CentOS7.6 operating system
How to install Apache Maven on CentOS 8
How to install Apache Kafka on CentOS 7
[Graphic] How to install tomcat on centos
R&D: How To Install Python 3 on CentOS 7
How to install GCC compiler on CentOS 7
Centos8 uses yum to install mongodb 4.2 method
Three ways to install JDK under CentOS
How to install offline JDK1.8 on centos7.0
Centos7 uses yum to install pip, ipython
Centos8 use yum to install rabbitmq tutorial
CentOS7 system yum way to install MySQL5.7
Centos6 install Python2.7.13