SCP Sink
Provided by: "Apache Software Foundation"
Support Level for this Kamelet is: "Stable"
Copies each message as a file to a directory on a remote server, with SCP (secure copy) over an SSH connection.
Use it to copy files to a server you reach with SSH that does not offer SFTP, for example to drop a configuration or a report on a host. To append to or keep existing files, or to create the directory when it is missing, use sftp-sink instead.
Input: the body is the content of the file, as text, bytes or a stream. The name of the file comes from the CamelFileName header, which may hold subdirectories, such as reports/data.csv; without it, a unique name is generated.
Output: the message is unchanged.
Good to know: files are written in directoryName, or else in the home directory of username, with the rights of that user, and a file with the same name is replaced. directoryName must exist: when it does not, every file is written as a file with the name of the directory. A file name that points outside the directory fails the message. The key of the server is checked against the file in knownHostsUri, or else ~/.ssh/known_hosts of the user that runs the integration, unless strictHostKeyChecking is no. Do not place it after messages from an untrusted source. Headers that start with CamelFile or CamelOverruleFile, except CamelFileName, are removed from the message first, so they cannot change what the Kamelet does.
Configuration Options
The following table summarizes the configuration options available for the scp-sink Kamelet:
| Property | Name | Description | Type | Default | Example |
|---|---|---|---|---|---|
Hostname | Required The host name or IP address of the server to copy the files to. | string | files.example.com | ||
Port | Required The SSH port of the server, usually 22. | string | 22 | ||
File Permissions | The permissions to give each new file, as three octal digits, such as | string | 640 | ||
Directory Name | The directory on the server to write the files to, such as | string | incoming/reports | ||
Known Hosts URI | A known_hosts file that holds the key of the server, such as one made with | string | |||
Password | The password of | string | |||
Private Key File | The path of a private key file on the machine that runs the integration, to log in with instead of a password. The matching public key must be in the | string | /etc/scp/keys/id_rsa | ||
Private Key Passphrase | The passphrase of the private key in | string | |||
Strict Host Checking | Whether the key of the server must be found in Enum values: * yes * no * ask | string | yes | ||
Use User Known Hosts File | If true, the key of the server is looked up in | boolean | true | ||
Username | The user to log in as. The files are written in the home directory of this user. | string |
Dependencies
At runtime, the scp-sink Kamelet relies upon the presence of the following dependencies:
-
camel:jsch
-
camel:kamelet
Camel JBang usage
Prerequisites
-
You’ve installed JBang.
-
You have executed the following command:
jbang app install camel@apache/camel Supposing you have a file named route.yaml with this content:
- route:
from:
uri: "kamelet:timer-source"
parameters:
period: 10000
message: 'test'
steps:
- to:
uri: "kamelet:scp-sink" You can now run it directly through the following command
camel run route.yaml SCP Sink Kamelet Description
Secure File Transfer
This Kamelet provides secure file transfer capabilities using SCP (Secure Copy Protocol). SCP enables encrypted file transfers over SSH connections, ensuring data security during transmission.
SSH-Based Security
Uses SSH protocol for authentication and encryption, providing strong security for file transfers across networks. Supports both password and key-based authentication methods.
Remote File Placement
Transfers files to directoryName on the remote server, or to the home directory of username when it is not set. A path without a leading / is relative to the home directory. The directory must exist: when it does not, each file is written as a file with the name of the directory. The file name comes from the CamelFileName header, which may include subdirectories, which are created; without it, a unique name is generated. A file with the same name is replaced. To create a missing directory, or to keep or append to existing files, use the SFTP Sink Kamelet.
Network Efficiency
SCP provides efficient file transfer capabilities suitable for:
-
Automated file deployments
-
Backup operations
-
Data distribution across systems
-
Secure file archiving
Authentication Methods
Supports multiple authentication methods:
-
Username and password authentication
-
Private key authentication (
privateKeyFile), withprivateKeyPassphrasefor a key protected by one -
Host key verification against the file in
knownHostsUri, or else~/.ssh/known_hostsof the user that runs the integration
Cross-Platform Support
Works across different operating systems and platforms, providing consistent secure file transfer capabilities regardless of the target system architecture.
Usage Example
- route:
from:
uri: "kamelet:timer-source"
parameters:
message: "Hello"
steps:
- setHeader:
name: CamelFileName
constant: "hello.txt"
- to:
uri: "kamelet:scp-sink"
parameters:
serverName: "files.example.com"
serverPort: "22"
username: "scpuser"
password: "scppass"
knownHostsUri: "/etc/scp/known_hosts"
directoryName: "incoming/reports"
chmod: "640" This copies hello.txt to incoming/reports in the home directory of scpuser, with the permissions 640. The umask of the server can take permissions away: with the usual umask 022, the default 664 gives 644. A file that already exists keeps its permissions, and only its content is replaced.