<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>question Re: Push .csv file from mid server to an SFTP location in Developer forum</title>
    <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754044#M410970</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I have managed to fix this. I had used gs.log multiple times as a result it was giving issue and also the package used for authentication was not correct. Here's the updated one. Please note, the fields marked with * in the code needs to be changed as per your config of the mid or SFTP&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;javascript probe:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var jprobe = new JavascriptProbe('*mid_server_name*'));&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.setName('SFTP File Transfer'); //any name can be given&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.setJavascript('new SFTP().fileTransfer();');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('host', '*target_host_name'));&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('port', '*port_name');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('user', '*user_id');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('privatekey', '*private_key_path');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('source', '*source_file_path');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('target', '');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('filename', '*file_name');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('deletefile', true);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.create();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Mid Script Include:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var SFTP = Class.create();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;SFTP.prototype = {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;initialize: function() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.File &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.io.File;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.J2ssh &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.com.sshtools.j2ssh;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.targetHost = probe.getParameter('host');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.targetPort = probe.getParameter('port');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.targetUser = probe.getParameter('user');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.privateKey = probe.getParameter('privatekey');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.targetFile = probe.getParameter('target') + probe.getParameter('filename');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.sourceFile = probe.getParameter('source') + probe.getParameter('filename');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.deleteFile = probe.getParameter('deletefile');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;},&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;fileTransfer: function() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;try {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this._sftp();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if (this.deleteFile) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this._deleteFile();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} catch (ex) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ms.log('SFTP Error: ' + ex);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;},&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;_authenticate: function(ssh) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;privateKeyFile = new this.J2ssh.transport.publickey.SshPrivateKeyFile.parse(new this.File(this.privateKey));&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;publicKeyAuth = new this.J2ssh.authentication.PublicKeyAuthenticationClient();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;publicKeyAuth.setUsername(this.targetUser);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;publicKeyAuth.setKey(privateKeyFile.toPrivateKey(''));&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var result = ssh.authenticate(publicKeyAuth);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if (result != new this.J2ssh.authentication.AuthenticationProtocolState().COMPLETE) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;throw 'SFTP Authenticate Failed: ' + this.targetUser + '@' + this.targetHost + ':' + this.targetPort;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;},&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;_deleteFile: function() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;try {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;new this.File(this.sourceFile)['delete']();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} catch (ex) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;throw 'SFTP Delete: ' + ex;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;},&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;_sftp : function() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ms.log('SFTP Connect: ' + this.targetUser + '@' + this.targetHost + ':' + this.targetPort);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var ssh = new this.J2ssh.SshClient();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;try {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ssh.connect(this.targetHost, this.targetPort, new this.J2ssh.transport.IgnoreHostKeyVerification());&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this._authenticate(ssh);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this._transfer(ssh);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} catch (ex) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;throw 'SFTP Error: ' + ex;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} finally {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ssh.disconnect();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;},&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;_transfer: function(ssh) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;try {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;sftp = ssh.openSftpClient();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;sftp.put(this.sourceFile, this.targetFile);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ms.log('SFTP Transfer: ' + this.sourceFile + ' copied to ' + this.targetHost + ':' + this.targetPort);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} catch (ex) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;throw 'SFTP Transfer: ' + ex;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} finally {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;sftp.quit();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;};&lt;/P&gt;&lt;BR /&gt;</description>
    <pubDate>Fri, 25 Aug 2017 13:49:33 GMT</pubDate>
    <dc:creator>ark6</dc:creator>
    <dc:date>2017-08-25T13:49:33Z</dc:date>
    <item>
      <title>Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754035#M410961</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have came across a requirement where I need to post a .csv file to my mid server and push to an SFTP location.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please note that my mid server is hosted in Linux and my SFTP location uses a public key authentication method .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For that I am using the export set, and try to call a script include through a javascript probe, but that doesnot seem to be working. Could any one please help?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A title="johnandersen" __default_attr="94636" __jive_macro_name="user" class="jive-link-profile-small jive_macro jive_macro_user" data-id="94636" data-objecttype="3" data-orig-content="johnandersen" data-renderedposition="178_8_104_16" data-type="person" href="https://www.servicenow.com/community?id=community_user_profile&amp;amp;user=a3d05e21db981fc09c9ffb651f96191a"&gt;johnandersen&lt;/A&gt; &lt;A title="ctomasi" __default_attr="2218" __jive_macro_name="user" class="jive-link-profile-small jive_macro jive_macro_user" data-id="2218" data-objecttype="3" data-orig-content="ctomasi" data-renderedposition="178_115.71875_67_16" data-type="person" href="https://www.servicenow.com/community?id=community_user_profile&amp;amp;user=7ae05a61db981fc09c9ffb651f9619a2"&gt;ctomasi&lt;/A&gt; please help me with this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My post export script:&lt;/P&gt;&lt;P&gt;var jprobe = new JavascriptProbe('mymid');&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jprobe.setName("Sftp File Transfer"); //any name can be given&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jprobe.setJavascript("var req = new SftpFile();req.FileTransfer();");&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jprobe.addParameter("targetPath",'test/test');&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jprobe.addParameter("keypath", '/home/myfolder/.ssh/');&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jprobe.addParameter("fileName", "ays_aptio_incident_data.csv");&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jprobe.addParameter("midServerTempPath", "/apps/opt/application/servicenow/midserver/agent/");&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jprobe.addParameter("deleteAfterUpload", true);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; jprobe.create();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My script include:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;var SftpFile = Class.create();&lt;/P&gt;&lt;P&gt;SftpFile.prototype = {&lt;/P&gt;&lt;P&gt; &amp;nbsp; initialize: function() {&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.Properties &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.util.Properties;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.StringUtil &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.com.glide.util.StringUtil;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.BufferedWriter &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.io.BufferedWriter;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.File &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.io.File;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.FileWriter &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.io.FileWriter;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.Encrypter &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = new Packages.com.glide.util.Encrypter();&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.FileOutputStream &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.io.FileOutputStream;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.FileInputStream &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.io.FileInputStream;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.BufferedReader &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.io.BufferedReader;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.InputStreamReader &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.io.InputStreamReader;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.OutputStraem &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.io.OutputStream;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.BufferedOutputStream = Packages.java.io.BufferedOutputStream;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.Thread &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.lang.Thread;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.targetServer = 'my-sftp-server';&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.targetPort =22 ;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.targetUsername = 'abc';&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; // this.targetPassword = 'testpassword';&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.deleteAfterUpload= probe.getParameter("deleteAfterUpload");&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.targetPath = probe.getParameter("targetPath");&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.MIDSERVER_FILE_PATH = probe.getParameter("midServerTempPath");&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.MIDSERVER_FILE_NAME = probe.getParameter("fileName");&lt;/P&gt;&lt;P&gt;this.MIDSERVER_PRIVATE_KEY_PATH = probe.getParameter("keypath");&lt;/P&gt;&lt;P&gt; &amp;nbsp; },&lt;/P&gt;&lt;P&gt; &amp;nbsp; &lt;/P&gt;&lt;P&gt;FileTransfer: function() {&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; var localFileName = this.MIDSERVER_FILE_PATH + "/" + this.MIDSERVER_FILE_NAME;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.log("Copying from local file of MID Server: " + localFileName);&lt;/P&gt;&lt;P&gt;gs.log("Copying from local file of MID Server: " + localFileName);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.sftpFile(this.targetServer, this.targetUsername, this.MIDSERVER_PRIVATE_KEY_PATH, localFileName, this.targetPath + this.MIDSERVER_FILE_NAME);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } catch (e) {&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.log("Error in writing file to SFTP server: " + e);&lt;/P&gt;&lt;P&gt;gs.log("Error in writing file to SFTP server: " + e);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt;sftpFile : function(hostName, userName, password, localFileName, remoteFileName) {&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.log('sftpFile(): attempting to connect to ' + hostName);&lt;/P&gt;&lt;P&gt;gs.log('sftpFile(): attempting to connect to ' + hostName);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //var ignoreHost = new Packages.com.sshtools.j2ssh.transport.IgnoreHostKeyVerification();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;keyfile = password+'id_rsa';&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; sshfile = new Packages.com.sshtools.j2ssh.transport.publickey.SshPrivateKeyFile.parse(new Packages.java.io.File(keyfile));&lt;/P&gt;&lt;P&gt;//this.log('key format'+sshfile.getFormat());&lt;/P&gt;&lt;P&gt;//this.log('key value'+sshfile.toString());&lt;/P&gt;&lt;P&gt;pk = new Packages.com.sshtools.j2ssh.authentication.PublicKeyAuthenticationClient();&lt;/P&gt;&lt;P&gt;//this.log('PUBLIC KEY METHOD'+pk.getMethodName());&lt;/P&gt;&lt;P&gt;pk.setUsername(userName);&lt;/P&gt;&lt;P&gt;pk.setKey(sshfile.toPrivateKey(null));&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; var ssh = new Packages.com.sshtools.j2ssh.SshClient();&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (!this.targetPort){&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.targetPort = 22;&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.log('sftpFile(): attempting to connect to ' + hostName + " on port " + this.targetPort);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ssh.connect(hostName, this.targetPort, ignoreHost);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // var pwd = new Packages.com.sshtools.j2ssh.authentication.PasswordAuthenticationClient();&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //var authPassword = new Packages.com.glide.util.Encrypter().decrypt(password);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // pwd.setUsername(userName);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // &amp;nbsp; pwd.setPassword(authPassword);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // Get full path of filename&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.log('sftpFile(): attempting to copy ' + localFileName + ' to ' + remoteFileName);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; //if(ssh.authenticate(pwd) == new Packages.com.sshtools.j2ssh.authentication.AuthenticationProtocolState().COMPLETE) {&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sftp = ssh.openSftpClient();&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try {&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sftp.put(localFileName, remoteFileName);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.log("File successfully copied to targert path\n\n");&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if (this.deleteAfterUpload == "true") {&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.log("deleteAfterUpload -&amp;gt; " + this.deleteAfterUpload + ", deleting local file...");&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new this.File(localFileName)["delete"]();&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch(e) {&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.log('FILE NOT FOUND ' + remoteFileName + ' or error: ' + e);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; sftp.quit();&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; try{&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // kill connection&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ssh.disconnect();&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; catch(e){&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; this.log('Manual connection kill not successful with error: ' + e);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; // &amp;nbsp; }&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; log: function(data) {&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ms.log(data);&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; },&lt;/P&gt;&lt;P&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;};&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2017 19:59:28 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754035#M410961</guid>
      <dc:creator>ark6</dc:creator>
      <dc:date>2017-08-23T19:59:28Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754036#M410962</link>
      <description>&lt;P&gt;Have you seen this on Share? &amp;nbsp; It may help solve your issue:&lt;/P&gt;&lt;BR /&gt;&lt;P class="ng-binding"&gt;&lt;A title="hare.servicenow.com/app.do#/detailV2/e5208f11e13fc2007c390227ffa71e0f/overview" href="https://share.servicenow.com/app.do#/detailV2/e5208f11e13fc2007c390227ffa71e0f/overview"&gt;File Builder FTP&lt;/A&gt;&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Aug 2017 20:14:38 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754036#M410962</guid>
      <dc:creator>Michael Ritchie</dc:creator>
      <dc:date>2017-08-23T20:14:38Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754037#M410963</link>
      <description>&lt;P&gt;Hi Michael,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Yes, I have seen this, but it also uses user id and password auth. not the public key authentication and also my code is a refrence from that one as well..&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 23 Aug 2017 21:07:27 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754037#M410963</guid>
      <dc:creator>ark6</dc:creator>
      <dc:date>2017-08-23T21:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754038#M410964</link>
      <description>&lt;P&gt;one the file is on MID server, Why don't you use Linux scheduled task to move the file to sftp server.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Aug 2017 18:54:46 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754038#M410964</guid>
      <dc:creator>SudhirOjha</dc:creator>
      <dc:date>2017-08-24T18:54:46Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754039#M410965</link>
      <description>&lt;P&gt;What is that? Can you explain please?&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Aug 2017 19:11:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754039#M410965</guid>
      <dc:creator>ark6</dc:creator>
      <dc:date>2017-08-24T19:11:36Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754040#M410966</link>
      <description>&lt;P&gt;I have windows server as MID server and i have created a task scheduler to move the files to sFTP location.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;IN task scheduler the batch file is called to deploy the files on to sFTP server using winscp tool.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;for more details how to move file in windows&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A href="https://www.itworld.com/article/2928599/windows/how-to-automate-sftp-file-transfers-in-microsoft-windows.html" title="https://www.itworld.com/article/2928599/windows/how-to-automate-sftp-file-transfers-in-microsoft-windows.html"&gt;How to automate SFTP file transfers in Microsoft Windows | ITworld&lt;/A&gt; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;There is a way in LINUX server also to move the files to sFTP using command. using PUT command&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A href="https://itservices.usc.edu/sftp/cline/" title="https://itservices.usc.edu/sftp/cline/"&gt;SFTP Using Command Line(UNIX, Mac OS X) | IT Services | USC&lt;/A&gt; &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Aug 2017 19:20:39 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754040#M410966</guid>
      <dc:creator>SudhirOjha</dc:creator>
      <dc:date>2017-08-24T19:20:39Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754041#M410967</link>
      <description>&lt;P&gt;Yes, thats fine, but for us we want to maintain it within servicenow. So trying to find a way how to do it through a probe&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Aug 2017 19:24:30 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754041#M410967</guid>
      <dc:creator>ark6</dc:creator>
      <dc:date>2017-08-24T19:24:30Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754042#M410968</link>
      <description>&lt;P&gt;ok --thats your choice... but we don't want to share the credentials outside our organization network--so we preferred that way to move data on sFTP.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Aug 2017 19:26:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754042#M410968</guid>
      <dc:creator>SudhirOjha</dc:creator>
      <dc:date>2017-08-24T19:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754043#M410969</link>
      <description>&lt;P&gt;I might have got it to work.. I will do a test and if it works I will update the thread &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_emote jive_macro" data-renderedposition="8_502.109375_16_16" src="https://www.servicenow.com/8.0.4.21bdc7e/images/emoticons/happy.png"&gt;&lt;/SPAN&gt; thanks.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 24 Aug 2017 19:31:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754043#M410969</guid>
      <dc:creator>ark6</dc:creator>
      <dc:date>2017-08-24T19:31:03Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754044#M410970</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I have managed to fix this. I had used gs.log multiple times as a result it was giving issue and also the package used for authentication was not correct. Here's the updated one. Please note, the fields marked with * in the code needs to be changed as per your config of the mid or SFTP&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;javascript probe:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var jprobe = new JavascriptProbe('*mid_server_name*'));&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.setName('SFTP File Transfer'); //any name can be given&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.setJavascript('new SFTP().fileTransfer();');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('host', '*target_host_name'));&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('port', '*port_name');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('user', '*user_id');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('privatekey', '*private_key_path');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('source', '*source_file_path');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('target', '');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('filename', '*file_name');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.addParameter('deletefile', true);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;jprobe.create();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Mid Script Include:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var SFTP = Class.create();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;SFTP.prototype = {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;initialize: function() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.File &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.java.io.File;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.J2ssh &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; = Packages.com.sshtools.j2ssh;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.targetHost = probe.getParameter('host');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.targetPort = probe.getParameter('port');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.targetUser = probe.getParameter('user');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.privateKey = probe.getParameter('privatekey');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.targetFile = probe.getParameter('target') + probe.getParameter('filename');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.sourceFile = probe.getParameter('source') + probe.getParameter('filename');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this.deleteFile = probe.getParameter('deletefile');&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;},&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;fileTransfer: function() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;try {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this._sftp();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if (this.deleteFile) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this._deleteFile();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} catch (ex) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ms.log('SFTP Error: ' + ex);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;},&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;_authenticate: function(ssh) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;privateKeyFile = new this.J2ssh.transport.publickey.SshPrivateKeyFile.parse(new this.File(this.privateKey));&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;publicKeyAuth = new this.J2ssh.authentication.PublicKeyAuthenticationClient();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;publicKeyAuth.setUsername(this.targetUser);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;publicKeyAuth.setKey(privateKeyFile.toPrivateKey(''));&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var result = ssh.authenticate(publicKeyAuth);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;if (result != new this.J2ssh.authentication.AuthenticationProtocolState().COMPLETE) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;throw 'SFTP Authenticate Failed: ' + this.targetUser + '@' + this.targetHost + ':' + this.targetPort;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;},&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;_deleteFile: function() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;try {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;new this.File(this.sourceFile)['delete']();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} catch (ex) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;throw 'SFTP Delete: ' + ex;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;},&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;_sftp : function() {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ms.log('SFTP Connect: ' + this.targetUser + '@' + this.targetHost + ':' + this.targetPort);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;var ssh = new this.J2ssh.SshClient();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;try {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ssh.connect(this.targetHost, this.targetPort, new this.J2ssh.transport.IgnoreHostKeyVerification());&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this._authenticate(ssh);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;this._transfer(ssh);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} catch (ex) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;throw 'SFTP Error: ' + ex;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} finally {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ssh.disconnect();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;},&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;_transfer: function(ssh) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;try {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;sftp = ssh.openSftpClient();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;sftp.put(this.sourceFile, this.targetFile);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;ms.log('SFTP Transfer: ' + this.sourceFile + ' copied to ' + this.targetHost + ':' + this.targetPort);&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} catch (ex) {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;throw 'SFTP Transfer: ' + ex;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;} finally {&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;sftp.quit();&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;}&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;};&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 25 Aug 2017 13:49:33 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754044#M410970</guid>
      <dc:creator>ark6</dc:creator>
      <dc:date>2017-08-25T13:49:33Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754045#M410971</link>
      <description>&lt;P&gt;Hi Arka,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I have similar requirement sending csv file to sftp server.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;The third party have given following details:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;1) ftp host name&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;2) ftp port 22&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;3) ftp username&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;4) ftp password&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;4) key file with '.ppk' file extension.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Is the following approach correct:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;1) load the ppk file to mid server location&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;2) follow your steps and mid server script and check whether the upload works&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Are you using some external jar file which you have uploaded to mid server?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Ankur&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 10 Nov 2017 11:32:30 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754045#M410971</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2017-11-10T11:32:30Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754046#M410972</link>
      <description>&lt;P&gt;Hi Ankur,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Sorry for the delay in reply.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Yes, we did in the same way. We uploaded the key file in our mid server location , following with the creation of export sets and mid server script includes.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Nov 2017 16:23:19 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754046#M410972</guid>
      <dc:creator>ark6</dc:creator>
      <dc:date>2017-11-13T16:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754047#M410973</link>
      <description>&lt;P&gt;Hi Arka,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Thanks for the details. I have few questions:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;1) was that a sftp server - I assume yes because it is port 22&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;2) was the key file a ppk file or with some other extension.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;3) Did you load some jar file for sftp package call in java&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Ankur&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Nov 2017 16:36:35 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754047#M410973</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2017-11-13T16:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754048#M410974</link>
      <description>&lt;P&gt;No we did it like below&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;We have created public keys for our mid servers with .pub extension and sent it to the SFTP team to add that on their end to establish a trust between the two systems.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Once we did that, we haven't needed a .jar file to install on our end.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 13 Nov 2017 17:32:57 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754048#M410974</guid>
      <dc:creator>ark6</dc:creator>
      <dc:date>2017-11-13T17:32:57Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754049#M410975</link>
      <description>&lt;P&gt;Hi Arka,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Got it. But in my case the sftp team has sent the key file which is a ppk file seems to be key file extension for putty application.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;May be I can check whether I can use password to connect without key file.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Ankur&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 14 Nov 2017 07:09:07 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754049#M410975</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2017-11-14T07:09:07Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754050#M410976</link>
      <description>&lt;P&gt;You could try with the username and password in FileZilla and check if you can access the SFTP location.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;If you can, then I believe it becomes easier.&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 15 Nov 2017 14:20:49 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754050#M410976</guid>
      <dc:creator>ark6</dc:creator>
      <dc:date>2017-11-15T14:20:49Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754051#M410977</link>
      <description>&lt;P&gt;Hi Arka,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;As per my earlier comment to this post I informed that the third party has given me the key file of putty.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I tried to connect and upload file to sftp with username, password, port(22) but getting SocketTimeOutException.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Not sure what is this for. the team informed that the folder was not present in the sftp server&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;The sftp server is in client internal network and the mid server is not in client network. the client network team has opened up the sftp port so that mid server can communicate over sftp port.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Do you think I should try using the key file as per the script mentioned by you by placing the key file in mid server location.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Can you provide some thoughts on this?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;STRONG style="color: #666666; font-family: arial, sans-serif;"&gt;We have created public keys for our mid servers with .pub extension and sent it to the SFTP team to add that on their end to establish a trust between the two systems.&lt;/STRONG&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;What exactly it means and how it has to be done?&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;We did not generate any key file and send to third party team yet.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Ankur&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Mon, 29 Jan 2018 14:43:03 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754051#M410977</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2018-01-29T14:43:03Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754052#M410978</link>
      <description>&lt;P&gt;Hi Ankur,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Sorry for the delay in reply. Not very much active in community now a days &lt;SPAN __jive_emoticon_name="happy" __jive_macro_name="emoticon" class="jive_emote jive_macro" data-renderedposition="50_473.8125_16_16" src="https://www.servicenow.com/8.0.4.21bdc7e/images/emoticons/happy.png"&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;If you have the keypairs, I believe that is sufficient to setup the trust between two systems. A userid/pass is not required in this case.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Your keypairs also need to be installed in the third party to setup a trust between two systems(public keys).&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;You may need to increase the timeout seconds to get rid of the socket Timeout exception. Below are few examples where they got rid of it by increasing the timeout seconds.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/15608499/getting-java-net-sockettimeoutexception-connection-timed-out-in-android" title="https://stackoverflow.com/questions/15608499/getting-java-net-sockettimeoutexception-connection-timed-out-in-android"&gt;Getting java.net.SocketTimeoutException: Connection timed out in android - Stack Overflow&lt;/A&gt; &lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;A href="https://examples.javacodegeeks.com/core-java/net/sockettimeoutexception/java-net-sockettimeoutexception-how-to-solve-sockettimeoutexception/" title="https://examples.javacodegeeks.com/core-java/net/sockettimeoutexception/java-net-sockettimeoutexception-how-to-solve-sockettimeoutexception/"&gt;https://examples.javacodegeeks.com/core-java/net/sockettimeoutexception/java-net-sockettimeoutexception-how-to-solve-soc…&lt;/A&gt; &lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 31 Jan 2018 19:50:36 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754052#M410978</guid>
      <dc:creator>ark6</dc:creator>
      <dc:date>2018-01-31T19:50:36Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754053#M410979</link>
      <description>&lt;P&gt;Hi Arka,&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Thanks for your reply.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;We don't have any key pairs generated by us. There is a key file which they have shared and they have shared details of sftp as well such port=22, hostname, password.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Till now I have not placed the key file in that mid server location and have not used code similar to yours to pick up that key file.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Format of key file they have shared:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;File name is : abc.ppk (seems to be extension for putty file)&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;PuTTY-User-Key-File-2: ssh-rsa&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Encryption: none&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Comment: imported-openssh-key&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Public-Lines: 6&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;// 6 lines of combination of numbers, chars, &amp;nbsp; special characters&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Private-Lines: 14&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;// 14 lines of combination of numbers, chars, &amp;nbsp; special characters&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Private-MAC:&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Should I check with them that the key file shared does it include the mid server and sftp trust in it or it is some file which is generic&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;I increased the timeout from 10sec to 40 sec but still the same error. It says java.net.SocketTimeoutException: Read timed out.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;The client network team has informed that they have opened the mid server IP incoming connection so that file can be sent over to sftp server.&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;BR /&gt;&lt;P&gt;Ankur&lt;/P&gt;&lt;BR /&gt;</description>
      <pubDate>Thu, 01 Feb 2018 04:59:15 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754053#M410979</guid>
      <dc:creator>Ankur Bawiskar</dc:creator>
      <dc:date>2018-02-01T04:59:15Z</dc:date>
    </item>
    <item>
      <title>Re: Push .csv file from mid server to an SFTP location</title>
      <link>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754054#M410980</link>
      <description>&lt;P&gt;Hi Ark&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried your script and it is only working by creating a file into my midserver but not more, it is not copiying the file into the sftp Server.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I run the Schedule Export I am getting in the log NULL Pointer Exception.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what I am doing wrong?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;Elias&lt;/P&gt;</description>
      <pubDate>Fri, 10 Aug 2018 11:25:58 GMT</pubDate>
      <guid>https://www.servicenow.com/community/developer-forum/push-csv-file-from-mid-server-to-an-sftp-location/m-p/1754054#M410980</guid>
      <dc:creator>Elias11</dc:creator>
      <dc:date>2018-08-10T11:25:58Z</dc:date>
    </item>
  </channel>
</rss>

