How to test sftp connection and file transfer via CLI?

Info:

This article provides steps to troubleshoot and further test SFTP file transfer.

Requirements:
  • A sftp users credentials with permissions to read and/or write to the intended source/destination folder.

Testing Connection:

  1. To test the connection to your SFTP server, please follow the syntax below:

sftp -P <PORT> [your_sftpuser]@[your_sftp_server_IP]
    1. sftp : sftp protocol/command

    2. -P: Port enabled for sftp connections on the SFTP server. By default this is 22.

    3. your_sftpuser: The sftp user that is allowed to establish connections.

    4. your_sftp_server_IP: destination SFTP server

  1. If the connection is successful, you will get a prompt to enter your sftp user password.

  2. If the connection is not successful, you can run the same command and add a -v flag before the port flag to obtain more debug information.

Testing File Transfer:

To test the transfer of files you can:

  1. Locate/Move to the destination/source folder of your remote machine. This will set the folder where you will uploading files from; or where you will be downloading files to.

sftp> lcd [DESTINATION_OR_SOURCE_FOLDER]
  1. (Optional) Move to the source or destination of your local SFTP server:

sftp> cd [SFTP_FOLDER_PATH]
  1. To upload files to your SFTP server:

sftp> put [Local_machine_filename] [DESTINATION_FOLDER_PATH]
  1. To download files from your SFTP server:

sftp> get [filename_path_on_remote_SFTP_server]

Check Folder Permissions

  1. To check the permissions on a folder, you can run the command below from inside an sftp session

ls -al
Support:

If Further Assistance is required, please proceed to log a support case or chat with our support engineer.