The N/keyControl module enables SuiteScript to manage cryptographic keys stored in the NetSuite Credential Store β primarily used for SFTP connections and secure key-pair authentication.
Using keyControl with SFTP
define(["N/keyControl", "N/sftp", "N/log"], (keyControl, sftp, log) => {
const hostKey = keyControl.get({ type: keyControl.Type.ECDSA_PUBLIC });
const conn = sftp.createConnection({
username: "sftpuser",
passwordGuid: "custscript_sftp_pwd_guid",
url: "sftp.example.com",
port: 22,
hostKey: hostKey
});
log.audit("SFTP connected", conn.url);
return {};
});
Key Types
| Key Type | Description |
|---|---|
keyControl.Type.ECDSA_PUBLIC | ECDSA public key for SSH/SFTP host verification |
keyControl.Type.RSA_PUBLIC | RSA public key |