You could store the password in a file encrypted by
crypt(1) get your script to decrypt it as it uses it, not very secure but it would hide the password from the casual observer.
I've used ftp with an input file to give the commands before, e.g.:
Code:
$ cat cmdfile.template
open _FTPSERVER_
user _USER_ _PASSWORD_
cd directory
binary
put tar.gz
bye
$
And then a script like this:
Code:
HOST=remote.host.name
USER=whoever
PASSWD=whatever
sed -e 's/_FTPSERVER_/'${HOST}'/' -e 's/_USER_/'${USER}'/' -e 's/_PASSWORD_/'${PASSWD}'/' cmdfile.template > cmdfile
ftp < cmdfile
If you wanted to hide the password then encrypt it into a file using crypt, e.g.:
Code:
$ echo passwdofchoice > clear
$ echo keyofchoice > key.file
$ crypt `cat key.file` < clear > password.crypt
$ rm clear
Changing key to be the decryption key and password to ones of your choice.
The in the above script "PASSWD=whatever" would change to:
Code:
KEY=`cat key.file`
PASSWD=`crypt ${KEY} < password.crypt`
The filenames could be made more obscure and as I said the whole thing is not secure but it would hide things a bit...
Using
scp to transfer files via SSH with
passwordless SSH would be preferable and more secure if your ftp server is also running
sshd.