How To Upload File Using Ftp Command In Linux
sFTP (secure File Transfer Programme) is a secure and interactive file transfer program, which works in a similar way equally FTP (File Transfer Protocol). Yet, sFTP is more than secure than FTP; it handles all operations over an encrypted SSH transport.
It tin can be configured to use several useful SSH features, such as public key authentication and compression. Information technology connects and logs into the specified remote machine, and switches to an interactive command mode where user tin can execute diverse commands.
In this article, we will show you how to upload/download a whole directory (including it'southward subdirectories and subfiles) using sFTP.
How to Use sFTP to Transfer Files/Directories in Linux
By default, SFTP adopts the same SSH transport for establishing a secure connection to a remote server. Although, passwords are used to authenticate users similar to the default SSH settings, only, it is recommended to create and apply SSH passwordless login for simplified and more secure connection to remote hosts.
Connect to Remote FTP Server Securely
To connect to a remote sftp server, kickoff institute an secure SSH connection and so create an SFTP session equally shown.
$ sftp [email protected]
Once you have logged into the remote host, you can run interactive sFTP commands as in the examples below:
sftp> ls #list directory sftp> pwd #print working directory on remote host sftp> lpwd #print working directory on local host sftp> mkdir uploads #create a new directory
How to Upload a Directory Using sFTP
In order to upload a whole directory to a remote Linux host, use the put control. However, you will get an mistake if the directory name doesn't exist in the working directory on the remote host as shown in the screenshot beneath.
Therefore, offset create a directory with the same proper name on the remote host, before uploading information technology from the local host, the -r
does the magic, enabling subdirectories and subfile to exist copied every bit well:
sftp> put -r Tecmint.com-articles sftp> mkdir Tecmint.com-articles sftp> put -r Tecmint.com-articles
To preserve the modification times, access times, and modes from the original files transferred, employ the -p
flag.
sftp> put -pr Tecmint.com-articles
How to Download a Directory Using sFTP
To download a whole directory chosen fstools-0.0 from remote Linux host to local motorcar, utilise the get control with the -r
flag as follows:
sftp> get -r fstools-0.0
Then check in the current working directory on the local host, if the directory was downloaded with all the contents in it.
To quite the sFTP shell, blazon:
sftp> cheerio OR sftp> leave
Additionally, read through the sFTP commands and usage tips.
Note that to forestall users from accessing the whole file system on the remote host, for security reasons, yous can restrict sFTP users to their habitation directories using chroot Jail.
That'due south it! In this article, we've showed you how to upload/download a whole directory using sFTP. Use the comment section beneath to offering u.s. your thoughts about this article/topic.
If Y'all Appreciate What We Do Hither On TecMint, Yous Should Consider:
TecMint is the fastest growing and most trusted customs site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you similar what you are reading, please consider buying us a coffee ( or 2 ) every bit a token of appreciation.
We are thankful for your never ending support.
Source: https://www.tecmint.com/sftp-upload-download-directory-in-linux/
Posted by: redmonatly1971.blogspot.com
0 Response to "How To Upload File Using Ftp Command In Linux"
Post a Comment