Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use sFTP to upload and download files in Linux

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly explains "how to use sFTP to upload and download files in Linux". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to upload and download files using sFTP in Linux".

Sftp is a secure file transfer protocol and is included in ssh, which means that sftp can be used as long as the sshd server is started, and its default port is the same as SSH 22. Sftp ensures the security of transferred files by using encryption / decryption technology, so the transmission efficiency of sftp is lower than that of ordinary FTP, but the security of sftp is higher than that of ftp, so sftp is usually used in scenarios with high security requirements, such as reports, statements and so on.

How to use sFTP to transfer files / folders in Linux

By default, the SFTP protocol establishes a secure connection to a remote server in the same way as the SSH transport protocol. Although user authentication uses passwords similar to the default settings of SSH, it is recommended that you create and use SSH password-less login to simplify and more securely connect to remote hosts.

To connect to a remote sftp server, establish a secure SSH connection and create a SFTP session as follows:

$sftp tecmint@192.168.56.10

After logging in to the remote host, you can run the interactive sFTP command as follows:

Sftp > ls # list directorysftp > pwd # print working directory on remote hostsftp > lpwd # print working directory on local hostsftp > mkdir uploads # create a new directory how to upload folders using sFTP

To upload the entire directory to a remote Linux host, use the put command. However, if the directory name does not exist in the working directory on the remote host, you will receive an error, as shown in the screenshot below.

Therefore, first create a directory with the same name on the remote host, and then upload it from the local host, and the-r parameter allows you to copy subdirectories and subfiles:

Sftp > put-r Tecmint.com-articlessftp > mkdir Tecmint.com-articlessftp > put-r Tecmint.com-articles

To retain the modification time, access time, and the mode of the file being transferred, use the-p flag.

Sftp > put-how to download folders using sFTP for pr Tecmint.com-articles

To download the entire fstools-0.0 folder to the local machine from a remote Linux host, use the get command with the-r flag as follows:

Sftp > get-r fstools-0.0 download directory using sFTP

If the folder has been downloaded, then look at the working directory on this machine.

To exit sFTP shell, enter:

Sftp > bye or sftp > exit

Please note that to prevent users from accessing the entire file system on the remote host, you can use chroot Jail to restrict sFTP users to their home directories for security reasons.

That's it! In this article, we showed you how to upload / download an entire directory using sFTP.

Thank you for your reading, the above is the content of "how to use sFTP to upload and download files in Linux". After the study of this article, I believe you have a deeper understanding of how to use sFTP to upload and download files in Linux. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report