SFTP: How to Copy Files from Local to Remote and from Remote to Local
This article will explore how to use SFTP to copy files, focusing on how to utilize the 'put' command to copy a file from your local machine to a remote server, and the 'get' command to download a file from a remote server to your local machine.
SFTP: Copy File from Local to Remote
To copy a file from your local machine to a remote server using SFTP, follow these steps:
Open a Terminal
: On Windows, you can use a program like PuTTY, while on Mac or Linux, you can simply use the built-in terminal.
Log in to the SFTP Server
: Type the following command, replacing "username" with your username and "hostname" with the IP address or domain of the remote server:
sftp username@hostname
Connect to the Server
: After entering the above command, you will be prompted to enter your password. Input the password to proceed. If successful, you'll enter an SFTP session.
Upload File to the Server
: Use the "put" command followed by the path of your local file to transfer it to the remote server. For instance:
put /path/to/local/file
SFTP: Copy File from Remote to Local
The process of copying a file from a remote server to your local machine is similar to the previous one, but with a slight twist:
Open a Terminal
: As with copying files from local to remote, you'll first need to open a terminal.
Log in to the SFTP Server
: Log in to the server using the same command as above:
sftp username@hostname
Connect to the Server
: Once again, you'll need to enter your password to continue. If you input the correct password, you'll enter the SFTP session.
Download File to Local Machine
: Use the "get" command followed by the path of your file on the remote server to download it to your local machine. For instance: