Hi, I need to make a SFTP connection from NetSuite...
# suitescript
r
Hi, I need to make a SFTP connection from NetSuite to a bank. like I will need a connection, and they will provide me a username, hostKey ,URL and Passguid right? and i just have to upload the file there at the given directory?
Copy code
var connection = sftp.createConnection({
        username: 'username',
        passwordGuid: '123456789',
        url: '<http://url.server.com|url.server.com>',
        hostKey: ''
    });
    //log.error('CONNECTION',connection);

    var myFileToUpload = file.create({
        name: internalID + '.json',
        fileType: file.Type.JSON,
        contents: postData,
        description: 'SO', 
        encoding: file.Encoding.UTF8
    });


    connection.upload({
    directory: username + '/',
    filename: internalID + '.json',
    file: myFileToUpload,
    replaceExisting: false
   });
b
sftp supports 2 authentication methods, the traditional username/password or a username/private key
your bank gets to choose which they support, which usually means the username/private key
its also unusual for them to provide the host key themselves, its something that you will have to manage
r
they use username/private key,
so they won't provide host key or password guid
then how am i suppose to get it?
b
i already gave the docs for managing the host key
Uploading Private SSH Keys goes over how to upload a private key to netsuite
keep in mind that its fairly common for the bank to generate the ssh keys themselves, so you want to check with the bank to see if they expect you to give them a public key or if they will give you a private key
r
they dont generate
they have told us to create the SSH keys
is this scary?
b
its normal for sftp
r
aha
what is the file format?
b
dont expect to be able to do this without learning how sftp works and how to use it
r
right
b
file format is upto the bank
r
what to i refer to learn ?
because i have to do it
b
best will probably be having access to a sftp server that you can practice with
r
right
what is a host key? is it the public key generated with ssh private key?
is that host?
b
there are 2 pairs of keys involved
the private key / public key of the server
and the private key / public key of the client (you)
the host key is the public key of the server
r
gotcha! okay the public key is the host key
and the passwors guid is the private key
password guid*
r
right
b
the password guid is used with the username/password combination
r
Copy code
var strHostKey = "AAAA888888888888888888888q7Rq1";

			  var objConnection = sftp.createConnection({
				  username: 'netsuite',
				  keyId: 'custkeynsacs_brav_edw_sftp',
				  url: '<http://secungs.com|secungs.com>',
				  port: 22,
				  hostKey: strHostKey
			  });
see here where i put the private key?
i mean here username and password
hostkey can is the public key
b
public key is too ambiguous
there are 2 pairs of keys
both with a public key
r
i give public key to the bank
and use the private key myself
in the hostkey: (myprivatekey) right?
i need to see how this exactly goes
b
the host key is unrelated to any of the keys you generate
its the public key of the sftp server
r
who will give me that?
and where will i use the private key
and what will i do of the public key?
b
i gave you 2 links to documentation earlier
you will need to read both of them
r
aha right
i will go through that
also one last question please
what is the MT102 for text file?
in wire transfers?
is that like a rule or something?
I can create that file, looks pretty simple.
but the ACH one creeps me out
its something CDD or CDX or PPP something
how do i generate that?
b
mt102 sounds like a swift file format
r
yes ye s
it is
are you god?
b
that was a quick search
r
but still the ACH one is i am concerned with
b
though i do recognize ach without searching
r
all these files do i create thorugh coding each line?
b
not sure about the swift one
the ach one has headers and trailers, so you will be doing summaries of lines
r
yeah exactly
so i have do ach through code right?
SFTP Connection suiteapp
b
Electronic Bank Payments is the netsuite feature related to generating bank payment files
its essentially generating payment files via templates
the sftp connector suiteapp is designed to move these files to bank via sftp
the functionality is implemented in suitescript, so a lot of the things in there will relate to suitescript apis
r
aha!
I will take a look at this, thanks!
I read the links you provided
Should i generate the private and public keys myself using putty
or IT support does it better?
also is the host key is the public key or should i ask the bank for it?