Sending data to an SFTP server
Connecting to an SFTP server
Section titled “Connecting to an SFTP server”To send data to a remote server over an SFTP connection, execute connect send sftp
with following mandatory parameters:
-h, --host
followed by the remote IP-l, --login
followed by the remote SFTP user login
Depending on the type of authentication you need to either use
-p, --password
then specify the password (for password-based authentication)--password-file
then specify the file containing the password
or
-i, --identity-file
specify the private key (for key based authentication)-k, --identity-passphrase
specify optional password to the private key--identity-passphrase-file
specify optional file containing the password to private key
Optionally, specify the target port if the remote server listens on a port other than 22/TCP:
--port
followed by the target TCP port
You can also set a timeout for network operations, which defaults to 30s. If the server is on a local network, consider lowering the timeout. If the server is slow or distant, consider increasing the timeout:
--timeout
followed by the timeout in seconds
Sending single file to an SFTP server
Section titled “Sending single file to an SFTP server”To send a single file to an SFTP server you should use
--file
followed by the file name to be sent
Following command will send file1.zip
file to [email protected]
SFTP server:
$ connect send sftp -h 10.0.0.24 -l monitor01 -p password --file file1.zip2025/06/02 08:22:23 INFO Files to send: count=1[file1.zip] 10.00 MiB / 10.00 MiB done
Sending multiple files to an SFTP server
Section titled “Sending multiple files to an SFTP server”If you’d like to send multiple files to an SFTP server you need to specify either file mask or file regular expression for the files.
--file-mask
a file mask--file-regex
regular expression
This will cause all files that match a certain mask or pattern to be sent. You can also provide an optional source folder that contains the files to be sent:
-s, --src-folder
If you don’t provide the source folder files will be sent from the current folder.
Following command will send all .zip
files from /data
folder to remote SFTP [email protected]
.
It will read the password from password-file
file and encrypt the file upon first read.
$ connect send sftp -h 10.0.0.24 -l monitor01 --password-file password-file --file-mask "*.zip" -s /data2025/06/02 08:25:12 INFO Files to send: count=3[file1.zip] 10.00 MiB / 10.00 MiB done[file2.zip] 10.00 MiB / 10.00 MiB done[file3.zip] 10.00 MiB / 10.00 MiB done
You can also provide an optional destination folder on the remote server:
-d, --dst-folder
If you don’t provide the destination folder files will be sent to the home folder of the user.
In below example all .zip
files from /data
folder will be sent to remote
folder at [email protected]
SFTP.
$ connect send sftp -h 10.0.0.24 -l monitor01 -i .ssh/id_ed25519 --file-mask "*.zip" -s /data -d remote2025/06/02 08:26:33 INFO Files to send: count=3[file1.zip] 10.00 MiB / 10.00 MiB done[file2.zip] 10.00 MiB / 10.00 MiB done[file3.zip] 10.00 MiB / 10.00 MiB done
Sending files in batch mode to an SFTP server
Section titled “Sending files in batch mode to an SFTP server”When using the application in batch or non-interactive mode, such as in a script or scheduler, you should disable the progress bar by using
--batch
to send files in batch mode
Following command will send all .zip
files from the /data
folder to the remote
folder on the SFTP server [email protected]
in batch mode:
It will read the password to the private key from passphrase-file
file and encrypt the file upon first read.
$ connect send sftp -h 10.0.0.24 -l monitor01 -i .ssh/id_ed25519 --file-mask "*.zip" -s /data -d remote --batch --identity-passphrase-file passphrase-file2025/06/02 08:41:23 INFO Files to send: count=32025/06/02 08:41:25 INFO Transferring file=/data/file1.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:41:26 INFO File transferred successfully bytesTransferred=10485760 duration=649ms transferRate=15.39MB/s file=/data/file1.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:41:26 INFO Transferring file=/data/file2.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:41:26 INFO File transferred successfully bytesTransferred=10485760 duration=198ms transferRate=50.48MB/s file=/data/file2.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:41:26 INFO Transferring file=/data/file3.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:41:27 INFO File transferred successfully bytesTransferred=10485760 duration=184ms transferRate=54.18MB/s file=/data/file3.zip sftpSessionID=1 targetFolder=remote
Sending files from scheduler to an SFTP server
Section titled “Sending files from scheduler to an SFTP server”When running the application from a scheduler, it’s recommended to ensure only one instance operates on a specific folder. To do that it’s possible to configure the application to create a flag file at startup and delete it upon completion. If another instance tries to start while one is already running, it will detect the flag file and exit. This approach ensures that only one instance of the application runs at any given time. To do that use
--flag
path to the flag file
Following command will send all .zip
files from /data
folder to the remote
folder on the SFTP server [email protected]
and uses /tmp/flag1
as a flag file.
Mind that we are using batch mode as it’s required for the application to run correctly from script or scheduler.
$ connect send sftp --flag /tmp/flag1 -h 10.0.0.24 -l monitor01 -i .ssh/id_ed25519 --file-mask "*.zip" -s /data -d remote --batch2025/06/02 08:49:14 INFO Using flag file: /tmp/flag12025/06/02 08:49:14 INFO Files to send: count=32025/06/02 08:49:16 INFO Transferring file=/data/file1.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:49:17 INFO File transferred successfully bytesTransferred=10485760 duration=560ms transferRate=17.83MB/s file=/data/file1.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:49:17 INFO Transferring file=/data/file2.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:49:17 INFO File transferred successfully bytesTransferred=10485760 duration=117ms transferRate=84.90MB/s file=/data/file2.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:49:17 INFO Transferring file=/data/file3.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:49:17 INFO File transferred successfully bytesTransferred=10485760 duration=213ms transferRate=46.93MB/s file=/data/file3.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:49:17 INFO Removing flag file: /tmp/flag1
Sending files in parallel to an SFTP server
Section titled “Sending files in parallel to an SFTP server”To speed up file delivery you can send files simultaneously. Application will then send files using multiple SFTP sessions. To specify number of concurrent SFTP sessions use:
--parallel
number of SFTP sessions
Following command will send all .zip
files from /data
folder to home folder of [email protected]
server using 3
parallel sessions.
$ connect send sftp -h 10.0.0.24 -l monitor01 -i .ssh/id_ed25519 --file-mask "*.zip" -s /data --batch --parallel 32025/06/02 08:51:49 INFO Files to send: count=32025/06/02 08:51:51 INFO Transferring file=/data/file3.zip sftpSessionID=2 targetFolder=2025/06/02 08:51:52 INFO Transferring file=/data/file2.zip sftpSessionID=1 targetFolder=2025/06/02 08:51:52 INFO Transferring file=/data/file1.zip sftpSessionID=3 targetFolder=2025/06/02 08:51:54 INFO File transferred successfully bytesTransferred=10485760 duration=1s848ms transferRate=5.41MB/s file=/data/file3.zip sftpSessionID=2 targetFolder=2025/06/02 08:51:54 INFO File transferred successfully bytesTransferred=10485760 duration=1s404ms transferRate=7.12MB/s file=/data/file1.zip sftpSessionID=3 targetFolder=2025/06/02 08:51:54 INFO File transferred successfully bytesTransferred=10485760 duration=1s891ms transferRate=5.29MB/s file=/data/file2.zip sftpSessionID=1 targetFolder=
Sending files in sequence to an SFTP server
Section titled “Sending files in sequence to an SFTP server”If you don’t specify the --parallel
option then files will be sent using single session in the same order as they showed up on the filesystem (oldest files first).
Action after file is delivered to an SFTP server
Section titled “Action after file is delivered to an SFTP server”After file is successfully delivered to remote location it’s possible to remove it from source or move it to a different folder at the source system.
--delete
delete a file after it’s delivered--move-folder
target folder to move the file after it’s delivered
Following command will send all .zip
files from /data
folder to remote
folder at [email protected]
server and then move the files to /archive
at the source system.
$ connect send sftp -h 10.0.0.24 -l monitor01 -i .ssh/id_ed25519 --file-mask "*.zip" -s /data -d remote --move-folder /archive --batch2025/06/02 08:54:06 INFO Files to send: count=32025/06/02 08:54:08 INFO Transferring file=/data/file1.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:54:09 INFO File moved to folder folder=/archive file=/data/file1.zip sftpSessionID=12025/06/02 08:54:09 INFO File transferred successfully bytesTransferred=10485760 duration=672ms transferRate=14.88MB/s file=/data/file1.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:54:09 INFO Transferring file=/data/file2.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:54:09 INFO File moved to folder folder=/archive file=/data/file2.zip sftpSessionID=12025/06/02 08:54:09 INFO File transferred successfully bytesTransferred=10485760 duration=239ms transferRate=41.79MB/s file=/data/file2.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:54:09 INFO Transferring file=/data/file3.zip sftpSessionID=1 targetFolder=remote2025/06/02 08:54:10 INFO File moved to folder folder=/archive file=/data/file3.zip sftpSessionID=12025/06/02 08:54:10 INFO File transferred successfully bytesTransferred=10485760 duration=199ms transferRate=50.12MB/s file=/data/file3.zip sftpSessionID=1 targetFolder=remote
Following command sends all .zip
files from /data
folder to home folder of [email protected]
and then removes the files from source.
$ connect send sftp -h 10.0.0.24 -l monitor01 -i .ssh/id_ed25519 --file-mask "*.zip" -s /data --batch --delete2025/06/02 08:55:53 INFO Files to send: count=32025/06/02 08:55:54 INFO Transferring file=/data/file1.zip sftpSessionID=1 targetFolder=2025/06/02 08:55:55 INFO File deleted file=/data/file1.zip sftpSessionID=12025/06/02 08:55:55 INFO File transferred successfully bytesTransferred=10485760 duration=652ms transferRate=15.32MB/s file=/data/file1.zip sftpSessionID=1 targetFolder=2025/06/02 08:55:55 INFO Transferring file=/data/file2.zip sftpSessionID=1 targetFolder=2025/06/02 08:55:55 INFO File deleted file=/data/file2.zip sftpSessionID=12025/06/02 08:55:55 INFO File transferred successfully bytesTransferred=10485760 duration=184ms transferRate=54.25MB/s file=/data/file2.zip sftpSessionID=1 targetFolder=2025/06/02 08:55:55 INFO Transferring file=/data/file3.zip sftpSessionID=1 targetFolder=2025/06/02 08:55:55 INFO File deleted file=/data/file3.zip sftpSessionID=12025/06/02 08:55:55 INFO File transferred successfully bytesTransferred=10485760 duration=181ms transferRate=54.96MB/s file=/data/file3.zip sftpSessionID=1 targetFolder=
All SFTP Send Options
Section titled “All SFTP Send Options”Usage: connect send sftp [command] [flags]
Flags: -h, --host string Destination sftp host -i, --identity-file string Private key file to use for authentication -k, --identity-passphrase string Private key passphrase --identity-passphrase-file string Private key passphrase file --idle uint Timeout for no network activity in seconds (default 60) -l, --login string Destination sftp host login -p, --password string Destination sftp host password --password-file string Destination sftp host password file --port uint Destination sftp host port (default 22) -t, --timeout uint Timeout for network operations in seconds (default 30)
Global Flags: --batch No progress bars --delete Delete files after successful send -d, --dst-folder string Folder where files should be sent --file string File name to be sent --file-mask string File mask to filter files for sending --file-regex string File regex to filter files for sending --flag string Flag file name --from-mail string From mail used to send notifications (only in batch mode) --godebug Turns on debug mode --help Prints help for the command --log-format string Log output format: text|json (default "text") --mail-format string Mail format [text|html] (only in batch mode) (default "plain") --move-folder string Folder to move files after successful send --no-color Do not use colors in logs --parallel uint Number of sessions used to send files (default 1) --quiet Makes no output -s, --src-folder string Folder containing files to be sent (default "./") --to-mail-failure strings Email list to send failure notification (only in batch mode) --to-mail-success strings Email list to send success notification (only in batch mode)
Errors
Section titled “Errors”Please check here for information on the possible errors.