Category: Linux Terminal

Added: 15th of September 2022

Viewed: 609 times

SFTP Secure file upload and download using the put and get commands in the Linux Terminal

To begin, open your terminal and create a new text file named test_file.txt on your Desktop. We will use this file to upload (put) and download (get)

touch /home/username/Desktop/test_file.txt

To connect to your remote server using SFTP enter your username followed by the ip address of your remote server

You will be prompted to enter your password
sftp username@ip_address

After successfully logging in to your remote server, you will be at the sftp prompt

Next create a new folder named upload on the remote server
makedir uploads

Uploading Files using the put command
To upload a file to the remove server using sftp we use the put command.
We need to specify the local path of the file to upload, followed by the remote path, the destination
put /home/username/Desktop/testfile.txt /home/username/uploads/

Download Files using the get command
To download a file to your local machine using sftp we use the get command.
We need to specify the remote path of the file to download, followed by the local path, the destination
get /home/username/uploads/test_file.txt /home/username/Desktop/test_file.txt

Please note: sftp will always overwrite the file, without any notification regardless of whether are using put or get