How To Use SFTP To Securely Transfer Files With A Remote Server

SFTP To Securely Transfer Files With A Remote Server

SFTP, also known as Secure File Transfer Protocol, is a file transfer method, which uses secure shell encryption that provides complete security while receiving or sending files. SFTP is used when a secure transfer of sensitive data is required. Get an SFTP server solution that’s highly scalable with no restrictions on the number of trading partners. The following steps demonstrate how to set up a secure file transfer using SFTP.

Generating SSH Keys

The first step is to generate SSH keys. This can be done as follows,

  • Open any terminal in a Linux computer or command prompt in Windows.
  • An RSA token can be set up by executing the terminal command “ssh-keygen -t rsa”.
  • Choose default (press enter) for any questions that pop up.
  • Set up a passphrase for security or keep it blank to log in without a password.
  • Two keys will be generated, where “id_rsa” is private and should be in your local computer, and “” is a public key and should be transferred to a remote server.

Copying SSH Keys

After generating, the SSH keys are copied onto a remote server. This takes place as follows,

  • Place the public RSA key on the remote server.
  • Execute the command “- ssh-copy-id user@serer_ip” to copy the file. The “user” is the remote server in the command, and the “server_ip” is its IP address.
  • A warning message may pop up on the screen, asking if you are sure you want to continue. For this, type “Yes” in the command line and press enter.
  • Another message with a warning that tells of the permanent addition of the “Server IP” to the list of hosts will pop up. It will mention the username and require a password. Type the password into it and enter.
  • You will be greeted with another message, which requires you to log into the machine with a username and check in.
  • Use the command “ssh user@server_ip” to log in to the remote machine every time.

Initiating SFTP Connection

This is the next step in the task, which is more straightforward than the previous ones,

  • Execute the command “sftp user@server_ip” in the command terminal where the “user” is the name and ‘server_ip” is IP address of the server.
  • If a successful connection is established, a SFTP prompt will be seen.

Transferring Files – Remote Servers to Local Systems

Here, transferring files from remote servers to local systems will take place,

  • Use the command “Syntax – get /path/to/remote/server/file.txt” in SFTP prompt.
  • After execution, you will see the file is copied into the local machine.
  • To download multiple files, use “Syntax – mget /path/to/remote/server/*.txt”.

Transferring Files – Local Systems to Remote Servers

Here, transferring files from local systems to remote servers will take place,

  • Use the command “Syntax – get file.txt /path/to/remote/server/directory” in the command terminal to copy the file from the local machine onto a remote server.
  • To move the file use command, “syntax – put /path/to/local/file/abc.txt /path/to/remote/directory”.
  • To transfer multiple files, use “mput/home/abc/*.txt /etc/config”.

Follow this elaborate step-by-step guide to transferring files securely using a remote server. SFTP file transfer plays a great role in the transfer among different data sources, and using it can be a big support to your company.

Tom Parillo

Tom Parillo

I am interested in all things technology, especially automation, robotics and tech that helps change how society will live in the future.