Using SSH to mount remote server directory under Ubuntu

           use SSH to mount the remote server directory under Ubuntu



Preface

                             . In Windows environment, you can map the remote server address to windows by mapping the network drive. Of course, there must be a corresponding tool under its old rival Linux, that is SSH. This article will take Ubuntu as an example to lead the readers to mount the remote server directory with SSH. The content of this article is not much. It's better to read the article and start at the same time. It's not too much fun.



1, Preliminary preparation

There are several steps that must be prepared before the official start-up of adb debugging. Otherwise, it's hard for a cunning woman to cook without rice.

  • At present, you have to install the Ubuntu operating system. As for the virtual machine installation or other ways, this is not the focus of this article. My Ubuntu version information is as follows. You can see that my current Ubuntu version information is 14.04. I won't explain it too much here.
tangkw@ubuntu:~/.android$ cat /proc/version
Linux version 3.19.0-25-generic (buildd@lgw01-20) (gcc version 4.8.2 (Ubuntu 4.8.2-19ubuntu1) ) #26~14.04.1-Ubuntu SMP Fri Jul 24 21:16:20 UTC 2015
tangkw@ubuntu:~/.android$ 
  • After installing the Ubuntu operating system, you must obtain the Root permission, which is not the focus of this article.
  • Copy the original. ssh signature folder assigned to you to your root directory, which is the key information you need to log in to the remote server. For example, the following. ssh folder
tangkw@ubuntu:~$ pwd
/home/tangkw
tangkw@ubuntu:~$ ls -a | grep .ssh
.ssh
tangkw@ubuntu:~$ cd .ssh/
tangkw@ubuntu:~/.ssh$ ls
id_rsa  id_rsa.pub  known_hosts
tangkw@ubuntu:~/.ssh$ 


2, Detailed steps

After the preparatory work, it is now ready to officially start. Sit down and drive.


2.1 install SSH tools first

Open the terminal, enter the following command under the terminal to install SSH tool. Since I have already installed it, I am prompted that there is no new need to install.

tangkw@ubuntu:~$ 
tangkw@ubuntu:~$ sudo apt-get install sshfs
[sudo] password for tangkw: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
sshfs is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 582 not upgraded.


After the installation is completed, you can directly enter ssh under the terminal to verify whether the ssh is installed. The command about ssh will not be introduced here too much. Later chapters will explain how to mount.


2.2 loading ssh to the kernel

Execute the following command to load into the kernel.

sudo modprobe fuse


2.3 setting related permissions

Set the relevant permissions required by SSH service, as follows:

tangkw@ubuntu:/$ sudo adduser $USER fuse
The user `tangkw' is already a member of `fuse'.
tangkw@ubuntu:/$ sudo chown root:fuse /dev/fuse
tangkw@ubuntu:/$ sudo chmod +x /dev/fuse 
tangkw@ubuntu:/$ 


2.4 start mounting

After the previous steps, now you can officially start to mount. Here, the mount directory I choose is the hgfs directory under my user directory. Of course, readers can also create a directory to mount by themselves. It depends on personal needs and hobbies. After all, everyone's aesthetic requirements are different.

tangkw@ubuntu:/$ cd ~/hgfs/
tangkw@ubuntu:~/hgfs$ pwd
/home/tangkw/hgfs
tangkw@ubuntu:~/hgfs$ 


Before the official start of mounting, the old rules explain the rules of ssh command as follows:

$ sshfs user@host:/remote_directory /local_directory 

Here, user @ host: / remote'directory represents the address and directory of our remote server, / local'directory represents the address to be mounted to our local address. Here we will bring the specific data into the above formula. My server address is tangkw@172.16.2.110:/home/tangkw, and the directory address is ~ / hgfs /. It's time to enter the command and witness the miracle.

tangkw@ubuntu:~$ sshfs tangkw@172.16.2.110:/home/tangkw ~/hgfs/
tangkw@172.16.2.110's password: 
tangkw@ubuntu:~$ cd ~/hgfs/
tangkw@ubuntu:~/hgfs$ ls
A910                                          Code sections for review-A920Pro_20190708T1.docx  ntfs.txt          repo          ssd    vfat.txt
Code sections for review-A77_20190708T1.docx  ~$de sections for review-A77_20190708T1.docx      PaxSPManager.rar  sourceisight  Tools
tangkw@ubuntu:~/hgfs$ 


Well, here you can enjoy the convenience of SSH.



epilogue

At this point of cultivation, congratulations to the readers that you have opened the way of Using SSH to mount the remote server directory under Ubuntu. There are any problems in walking around Ubuntu. At this time, you can go all over the world with one sword, and the necessary weapon for the master has been given to each other. See you in the Jianghu.



Written in the end

                       . At the end of the article, if this article is helpful to you, please pay attention to and praise it. Of course, if there are mistakes and shortcomings, you can also make bricks.

92 original articles published, 95 praised, 320000 visitors+
Private letter follow

Tags: Ubuntu ssh sudo Windows

Posted on Thu, 16 Jan 2020 10:26:06 -0500 by aktell