Create and attach a Linux/Unix SSH Authorized User key to your SBI user in Sterling B2B Integrator.
srbrandon 2700007D78 Visits (3403)
It’s very easy to send a batch of files from a Windows server to Sterling B2B Integrator(SBI), by using popular sftp clients (such as Filezilla or WinSCP).
Linux/Unix inherently comes with an sftp utility, which can be used to create shell scripts to directly send files via sftp to any SFTP server. One caveat is that every time the sftp put command is executed in Linux/Unix, it will ask the sftp user's password interactively.
This is a guideline on how to set up SBI so that a shell script from Linux/Unix doesn't prompt your SBI sftp user for a password.
1. The first step is to create a user key from your Linux/Unix system.
To generate an user key run the following command from your Linux/Unix host:
Press <enter> for every option to take the defaults.
myuser@myserver:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/ho
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /hom
Your public key has been saved in /hom
The key fingerprint is:
The key's randomart image is:
+--[ RSA 2048]----+
| ooB. |
| C . |
| o . |
| o. .. |
| ...R . |
| o. o o |
| oo + o |
|.... . . . |
|+o. oE |
2. Take the public part of the key and check it into SBI.
This is the public key: /hom
(I copied it into my Windows workstation and renamed it public_id_rsa.pub).
Then Go to the Authorized User Key menu on the SBI dashboard.
Click Go under Check In "Authorized User Key”.
Choose a Key Name and click on “Browse” to point to the public key file generated on step 1.
Click “Next” and you should see a confirmation page and then click Finish.
3. Next, you need to attach the SSH Key to your SBI sftp user. Go to Accounts -> User Accounts under the SBI dashboard.
This assumes there's already an User Account created. We're just attaching the SSH Authorized User Key.
Choose your userAccount and click Next until you get to the SSH Authorized User Key. Choose the key we checked in on step 2.
Click Next until you finish editing the user.
Now your sftp user has the Linux/Unix SSH authorized key attached.
Here's a simple shell script you can run from your Linux/Unix host (where you generated the SSH key). It should not prompt you for a password as long as you're using the SBI user that has the SSH authorized key attached.
while [ $COUNTER -lt 10 ]; do
(echo put testFile upload.$COUNTER; echo quit) | sftp -oPort=SBIPort myuser@SBIIPAddress >/dev/null 2>&1
echo Finished in $((end-start)) seconds.
rm -f upload.*
**Please note: The above script will loop the sftp put command 10 times. You can adjust the counter to your testing needs. The script needs to be updated for your port, user & sbi ip address. In addition, this script expects a file called testFile in the same directory where the script is located. You can modify this script to your needs.
I hope you find these steps helpful to test your SBI SFTP server adapter from a Linux/Unix shell script.