- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-21-2025 10:21 PM
Hi,
I have been using J2ssh library in mid server script include. However, the SFTP server no longer supports this encryption algorithm. I want to upgrade to SNCSSH. Can anyone let me know how to proceed with this.
The requirement is to push the CSV file from MID Server to target SFTP Server.
var SFTP = Class.create();
SFTP.prototype = {
initialize: function() {
this.File = Packages.java.io.File;
this.J2ssh = Packages.com.sshtools.j2ssh;
this.targetHost = probe.getParameter('host'); //hostname or IP address of the SFTP server
this.targetPort = probe.getParameter('port');
this.targetUser = probe.getParameter('user');
this.targetPassword = probe.getParameter('password');
this.targetFile = probe.getParameter('target') + probe.getParameter('filename');
this.sourceFile = probe.getParameter('source') + probe.getParameter('filename');
this.deleteFile = probe.getParameter('deletefile');
},
fileTransfer: function() {
try {
this._sftp();
if (this.deleteFile) {
this._deleteFile();
}
} catch (ex) {
ms.log('SFTP Error: ' + ex);
}
},
_authenticate: function(ssh) {
var passwordAuth = new this.J2ssh.authentication.PasswordAuthenticationClient();
passwordAuth.setUsername(this.targetUser);
passwordAuth.setPassword(this.targetPass);
var result = ssh.authenticate(passwordAuth);
if (result != new this.J2ssh.authentication.AuthenticationProtocolState().COMPLETE) {
throw 'SFTP Authenticate Failed: ' + this.targetUser + '@' + this.targetHost + ':' + this.targetPort;
}
},
_deleteFile: function() {
try {
new this.File(this.sourceFile)['delete']();
} catch (ex) {
throw 'SFTP Delete: ' + ex;
}
},
_sftp: function() {
ms.log('SFTP Connect: ' + this.targetUser + '@' + this.targetHost + ':' + this.targetPort);
var ssh = new this.J2ssh.SshClient();
try {
ssh.connect(this.targetHost, this.targetPort, new this.J2ssh.transport.IgnoreHostKeyVerification());
this._authenticate(ssh);
this._transfer(ssh);
} catch (ex) {
throw 'SFTP Error: ' + ex;
} finally {
ssh.disconnect();
}
},
_transfer: function(ssh) {
try {
sftp = ssh.openSftpClient();
sftp.put(this.sourceFile, this.targetFile);
ms.log('SFTP Transfer: ' + this.sourceFile + ' copied to ' + this.targetHost + ':' + this.targetPort);
} catch (ex) {
throw 'SFTP Transfer: ' + ex;
} finally {
sftp.quit();
}
}
};Please let me know if the requirement can be achieved through any other way.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-22-2025 09:12 AM - edited ‎09-22-2025 09:13 AM
Sure @hameetkaur,
For SSHJ:
You will need the main sshj JAR and at least one logging JAR from SLF4J (a common dependency).
Download Links (Maven Central):
SSHJ JAR: https://search.maven.org/artifact/com.hierynomus/sshj
SLF4J JARs (Dependencies): SSHJ requires a logging facade. You'll need two more JARs.
SLF4J API: https://search.maven.org/artifact/org.slf4j/slf4j-api
SLF4J Simple (for logging to console): https://search.maven.org/artifact/org.slf4j/slf4j-simple
For Apache MINA SSHD:
Apache MINA SSHD Project: https://mina.apache.org/sshd-project/downloads.html
You will typically need to download the binary distribution (.zip or .tar.gz) which contains all the necessary JARs in its lib folder, including sshd-core, sshd-sftp, and its dependencies like slf4j-api. This is often easier than finding each JAR individua
Implementation steps:
Stop the MID Server service.
Copy all the required JAR files (e.g., sshj-0.38.0.jar, slf4j-api-2.0.12.jar, slf4j-simple-2.0.12.jar) into the agent/lib directory of your MID Server.
Start the MID Server service.
Create a new MID Server Script Include and use the Java classes from the library to write your SFTP logic. You will use Packages.com.hierynomus.sshj... to access the SSHJ classes.
Note: The library version you choose must be compatible with the Java version used by your MID Server. Recent ServiceNow releases (e.g., Vancouver, Washington DC) typically use Java 11. You should verify this by checking the java -version command in your MID Server's agent/jre/bin directory. Select the latest library version that supports your MID Server's Java version.
Hope this cleared all the things now!
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution and helpful so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2025 01:25 AM
Hi @hameetkaur,
The "Procurement File Transfer Framework" is a specialized, application-specific tool and is not the correct one for your general requirement.
The spoke you need is the SFTP Spoke, which is a core component of ServiceNow's IntegrationHub. It is not a separate store app but is included with an IntegrationHub subscription (typically IH-Starter or higher).
Hope this helps!
Thanks & Regards,
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution and helpful so others can benefit as well.
Muhammad Iftikhar
If my response helped, please mark it as the accepted solution so others can benefit as well.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-23-2025 06:07 AM
Hi @M Iftikhar
I installed ServiceNow IntegratationHub Professional Pack starter in my PDI. However, i am not able to see SFTP Spoke option in the flow designer.
