It is currently Tue, 17 May 2022 17:38:46 GMT



 
Author Message
 Encrypting ftp password in ftp batch script???
Help,

I'm trying to write a ftp batch script, but I want the password not to be in
plain text.  So is there a simple way to put the password in a another file that
is encrypted and then decrypt it into a variable then put that in my ftp batch
script.

Or is there a simple ksh command to encrypt/decrypt text?

Thanks.



 Mon, 13 Oct 2003 07:16:42 GMT   
 Encrypting ftp password in ftp batch script???

These are fun problems ;)

Anyway, here's a small example script which basically crypts a string and
convert it to "-" delimited octals (Coder). For decoding, the string is
processed the other way around.
You can hard-code the crypt-key or "hide" it somewhere not in plain view. In
stead of using plain text passwords, you can use the octal-serie
representation.

Don't forget this is not much different from storing plain text passwords
(security by obscurity).

If it doesn't solve your problem, it'll perhaps give you an idea of how to
proceed.

Bye,
Real

#!/usr/bin/ksh

function Coder
{
   # Usage: Coder <text> <key>
   echo "${1}\c" | crypt ${2} | od -t oC -v -w512 | sed -e 's/^[0-9]*[ ]*//'
| tr -d '\n' | tr ' ' '-'
   return

function Decoder
{
   # Usage: Decoder <pwd> <key>
   echo "$( echo "\\\\0${1}" | sed -e 's/[-]/\\0/g' )\c" | crypt ${2}
   return

coded="$( Coder "SuperSecretPassword" "secret" )"
echo "Coded  : ${coded}"

decoded="$( Decoder "${coded}" "secret" )"
echo "Decoded: ${decoded}"

exit



 Mon, 13 Oct 2003 17:46:59 GMT   
 Encrypting ftp password in ftp batch script???

I wouldn't recommend it. It'll only give you a false sense of security. If
you can easily decode it, so can everyone else. If not, and they REALLY want
to get their hands on your password, they'll simply sniff it off the
network. Look at ssh/scp instead.

====================================================================
S?ren Hansen
UNIX Systems Administrator
Mindpass.com, Vardevej 1, DK-9220 Aalborg
Reception: +45 9635 2000, GSM: +45 2077 3385, fax: +45 9635 2099
s...@mindpass.com



 Mon, 13 Oct 2003 22:22:23 GMT   
 Encrypting ftp password in ftp batch script???

Use a .netrc file (man ftp or man netrc).  The .netrc file is not
encrypted, but it can have 700 permission (only the owner or root
can read it).  If you want to let other users use the script, they will
need their own passwords.



 Tue, 14 Oct 2003 02:52:01 GMT   
 
   [ 4 post ] 

Similar Threads

1. secure ftp batch binaries/scripts

2. Batch ftp from shell script

3. Ftp batch script file anyone have an example

4. ftp batch script file?

5. running ftp in batch mode via shell script

6. Running ftp in batch mode via shell script

7. Scripting FTP tasks - How to use FTP in bash scripts

8. I want an ftp script so I dont have to enter the password ecerytime

9. Submit password to NON-anonymous ftp site from a shell script

10. ftp script shells problem if no password necessary


 
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software