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 under Linux

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article will explain in detail how to use SFTP under Linux. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

SFTP is the abbreviation of SSH File Transfer Protocol, secure file transfer protocol. SFTP and FTP have almost the same syntax and function. SFTP, which is part of SSH, is a secure way to transfer files to a Blogger server.

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:

After sftp tecmint@192.168.56.10 logs 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 a folder 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 the 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.

This is the end of the article on "how to use SFTP under Linux". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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