Note: when this class is used with sensitive data, be careful in persisting sensitive information.
An example usage is as follows:
var sftp : SFTPClient = new dw.net.SFTPClient();
sftp.connect("my.sftp-server.com", "username", "password");
var data : String = sftp.get("simple.txt");
sftp.disconnect();
The default connection timeout depends on the script context timeout and will be set to a maximum of 30 seconds (default script context timeout is 10 seconds within storefront requests and 15 minutes within jobs).
IMPORTANT NOTE: Before you can make an outbound SFTP connection to a port other than 22, the SFTP server IP address must be enabled for outbound traffic at the Commerce Cloud Digital firewall for your POD. Please file a support request to request a new firewall rule.
SSH Version 2 is supported with the following algorithms:
Type | Algorithms |
---|---|
Host Key | ssh-ed25519, ecdsa-sha2-nistp256, ecdsa-sha2-nistp384, ecdsa-sha2-nistp521, rsa-sha2-512, rsa-sha2-256, ssh-rsa, ssh-dss |
Key Exchange (KEX) | curve25519-sha256, [email protected], ecdh-sha2-nistp256, ecdh-sha2-nistp384, ecdh-sha2-nistp521, diffie-hellman-group-exchange-sha256, diffie-hellman-group16-sha512, diffie-hellman-group18-sha512, diffie-hellman-group14-sha256, diffie-hellman-group14-sha1, diffie-hellman-group-exchange-sha1, diffie-hellman-group1-sha1 |
Cipher | aes128-ctr, aes192-ctr, aes256-ctr, [email protected], [email protected], aes128-cbc, 3des-ctr, 3des-cbc, blowfish-cbc, aes192-cbc, aes256-cbc |
Message Authenticaton Code (MAC) | [email protected], [email protected], [email protected], hmac-sha2-256, hmac-sha2-512, hmac-sha1, hmac-md5, hmac-sha1-96, hmac-md5-96 |
Public Key Authentication | rsa-sha2-512, rsa-sha2-256, ssh-rsa |
This method associates the key to the host used in the subsequent connect method, and must be called prior to connect. The key is not persisted, and is only associated to this instance of the SFTP client.
Multiple keys may added, and the validation will succeed if the remote host matches any of them.
The default behavior is to persist and trust an unknown host key if there are no known host keys available. If addKnownHostKey is later used to trust specific a specific key or keys, then any previously persisted keys will be ignored.
null
if not present.
null
if not present.
null
if not present.
NOTE: If the remote file already exists, it is overwritten.
NOTE: If the remote file already exists, it is overwritten.
The key is only associated to this instance of the SFTP client.
The maximum and default timeout depend on the script context timeout. The maximum timeout is set to a maximum of 2 minutes. The default timeout for a new client is set to a maximum of 30 seconds.
This method can be called at any time, and will affect the next connection made with this client. It is not possible to set the timeout for an open connection.