Topic
4 replies Latest Post - ‏2012-12-01T14:33:07Z by SystemAdmin
SystemAdmin
SystemAdmin
6908 Posts
ACCEPTED ANSWER

Pinned topic sftp file into the target system with encrypted password

‏2012-11-30T19:01:16Z |
We are praparing a script to move a file from AIX 6.1 to other system.

we are using the below script"put_etransfer.ksh"

#!/usr/bin/ksh
sftpdate=`date +"%Y%m%d%H%M"`
filename=hsa-selectacc.asc
logfile=/home/data/interfaces/log/etransfer_$sftpdate.log
cd /home/data/usinterfaces/out
if ! -e $FILENAME
then
print "ERROR - $FILENAME does not exist."
print "Exitting ..."
exit 1
fi
/usr/local/bin/sftp -B /home/hrdata/scripts/USsftp/cmdc.sftp qaz00100@move.etransfer.com >> $logfile


here cmdc.sftp conatains below commands
binary
ls -l
put hsa-selectacc.asc
exit
==========================================================
when we execute put_etransfer.ksh we get error message

./put_esecuretransfer.ksh
Error: Could not open connection to `qaz00100@move.etransfer.com': Could not connect to `move.etransfer.com': Disconnected by application
when I change the script to
#!/usr/bin/ksh
sftpdate=`date +"%Y%m%d%H%M"`
FILENAME=hsa-selectacc.asc
logfile=/home/hrdata/usinterfaces/log/etransfer_$sftpdate.log
cd /home/hrdata/usinterfaces/out
if ! -e $FILENAME
then
print "ERROR - $FILENAME does not exist."
print "Exitting ..."
exit 1
fi
sftp qaz00100@move.etransfer.com

and execute the script put_etransfer.ksh
It will ask for password and if I provide the password it will get connected but i need to give the command put hsa-selectacc.asc

Can any one help me on this.

Thanks inadvance
Viswanath
Updated on 2012-12-01T14:33:07Z at 2012-12-01T14:33:07Z by SystemAdmin
  • unixgrl
    unixgrl
    185 Posts
    ACCEPTED ANSWER

    Re: sftp file into the target system with encrypted password

    ‏2012-11-30T19:27:42Z  in response to SystemAdmin
    If I understand what you are trying to do I think you need to either:
    a) have ssh keys between the two systems that will allow password-less transfer
    b) put the password in the command file "passwd <yourpasswordhere>"

    There may be another way to pass in the password like we used to with .netrc files but it would be dependent on the sftp you are using and whether your company allows you to do that.
    • SystemAdmin
      SystemAdmin
      6908 Posts
      ACCEPTED ANSWER

      Re: sftp file into the target system with encrypted password

      ‏2012-12-01T08:38:50Z  in response to unixgrl
      Hi Sir,

      I am not allowed to give password in the command line.In this case I need to encrypt the password.

      how can I encrypt the password.

      Thanks,
      Viswanath
      • SystemAdmin
        SystemAdmin
        6908 Posts
        ACCEPTED ANSWER

        Re: sftp file into the target system with encrypted password

        ‏2012-12-01T13:37:52Z  in response to SystemAdmin
        Hi,

        updated the script with below line
        export password=abcdxy123

        still it pormpts for password

        Thanks,
        Viswanath
      • SystemAdmin
        SystemAdmin
        6908 Posts
        ACCEPTED ANSWER

        Re: sftp file into the target system with encrypted password

        ‏2012-12-01T14:33:07Z  in response to SystemAdmin
        Putting the password into a file isn't much more secure that not using it when sending the command.

        As already suggested, have you checked out using ssh/scp? Setting up passwordless keys would be more secure and easier to do.