Linux Application Essay (7) Interacting with Linux Server to Transfer Files

Since I am using the Aliyun student version, I decided to replace the previous winserver with debian in the afternoon. So how to realize the two-way transfer of files? You can use the sshfs command to mount the remote directory locally, or you can use the sftp command.
The first one: use sshfs.

sudo apt-get install sshfs
sshfs -o allow_other root@xxx.xxx.xxx.xxx:/var/www/html ~/mnt/remote/apache

In this way, the server's apache2 project path /var/www/html is mounted to its own local folder. Of course, the local folder can be created and specified by itself.
This method can directly open the remote directory on the file browser, which is very convenient. However, you need to set the remote directory to be permanently mounted, otherwise the file browser will get stuck after a while:

sudo vim /etc/fstab

Add the following content at the bottom, you need to ensure that SSH key-based authentication is configured before automatic mounting:

root@xxx.xxx.xxx.xxx:/var/www/html ~/mnt/remote/apache fuse.sshfs
IdentityFile=~/.ssh/id_rsa defaluts 0 0

After modifying the file, mount it:

sudo mount -a

The second method: use sftp.
sudo apt-get install sitecopy
will have the sftp command after installation.
sftp [email protected]
Next, you can enter help to view the command, and exit with exit .
It should be noted that pwd, ls, rm, mkdir and other commands can be used directly to operate the remote host. If you operate the local host, add l before the command, such as lls.
In addition, get can download files, and put can upload files.
get /var/www/html/index.php /home/canva/
put /home/canva/countryside.war /var/lib/tomcat7/webapps

Guess you like

Origin blog.csdn.net/CanvaChen/article/details/52810787