How to test sftp connection and file transfer via CLI?
This article provides steps to troubleshoot and further test SFTP file transfer.
- A sftp users credentials with permissions to read and/or write to the intended source/destination folder.
Testing Connection:
- To test the connection to your SFTP server, please follow the syntax below:
sftp -P <PORT> [your_sftpuser]@[your_sftp_server_IP]
- sftp : sftp protocol/command
- -P: Port enabled for sftp connections on the SFTP server. By default this is 22.
- your_sftpuser: The sftp user that is allowed to establish connections.
- your_sftp_server_IP: destination SFTP server
If the connection is successful, you will get a prompt to enter your sftp user password.
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:
- 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]
- (Optional) Move to the source or destination of your local SFTP server:
sftp> cd [SFTP_FOLDER_PATH]
- To upload files to your SFTP server:
sftp> put [Local_machine_filename] [DESTINATION_FOLDER_PATH]
- To download files from your SFTP server:
sftp> get [filename_path_on_remote_SFTP_server]
Check Folder Permissions
- To check the permissions on a folder, you can run the command below from inside an sftp session
ls -al
If Further Assistance is required, please proceed to log a support case or chat with our support engineer.