Jump to Navigation

236 - SFTP public key authentication

You have few options other than using public key authentication:

    Use keychain
    Use sshpass (less secured but probably that meets your requirement)
    Use expect (least secured and more coding needed)

This is a sample on sshpass.

Need to download the package and install it into the linux box :
RedHat does not provide this package from RHN.

http://rpm.pbone.net/index.php3/stat/45/idpl/17273067/numer/1/nazwa/sshpass

sshpass-1.05-1.el5.x86_64.rpm

Sample 1 :

#!/bin/bash
export SSHPASS=your-password-here
sshpass -e sftp -oBatchMode=no -b - sftp-user@remote-host << !
   cd incoming
   put your-log-file.log
   bye
!

Sample 2 :

#!/bin/bash
HOST='xxxx.xxxx.com'
USER='xxxxxxxxx'
LOG=sshpass.log
export SSHPASS=<password>
sshpass -e sftp -oBatchMode=no -b ./trans-batch $USER@$HOST >> $LOG

< trans-batch >
---------------------------------------
cd ./INBOUND
mput /d01/taxware/tkout/*.out
pwd
ls
bye
--------------------------------------

 

Linux:


Main menu 2

Story | by Dr. Radut