Page 1 of 1

Hiding userid and password in ftp script

Posted: Thu Sep 20, 2007 7:07 am
by horserider
I am running a ftp script as below and it works fine.

ftp -v -n abc.syscon.com
user adminuser login1q2w3e
lcd /company/user/shellscripts
put flatfile.txt flatfile.txt
put
bye

I am hardcoding the userid and password in FTP script. Anyway, to hide the userid/password in ftp script? Bascially I don't want to type the details, for other people to see (in case they get the ftp script)

Posted: Thu Sep 20, 2007 7:13 am
by chulett
I don't believe so - Google around and see what you can find out.

:idea: If you switch to a secure method, sftp or scp, and setup RSA keys you can perform the transfer without 'needing' a password.

Posted: Fri Sep 21, 2007 8:37 am
by landaghaar
Well you could create environment variables for userid and passwords in your .profile or create a .ftp file like this:


export USERID='the user id you want to use'
export PASSWD='your ftp password'


then in your ftp script just call this script by

. /full/path/to/.ftp
ftp -v -n abc.syscon.com
user $USERID $PASSWD
lcd /company/user/shellscripts
put flatfile.txt flatfile.txt
put

good enough?

but as chulett suggested, it is better to use sftp or scp, but only if the server supports it.