How to do ftp from UNIX to windows machine?

hi,

i am using ftp command to transfer files from unix server to windows server using a web interface.
there is a shell script which is called by the web page which executes a ftp command which (ftp) tries to connect to the windows machine and asks for username and password.

so in order to complete the ftp i thought of two methods
1) i need to pass the username and password to the shell script via command line arguments from the web page.

2) store the windows machine name and the password in a file which is read by the shell script.

in both these methods i think there is a security threat to the windows machine since any 1 can hack the password.

so plz help me out how to do this.
can we do ftp from unix to windows without using username and password?
is there any other protocol to transfer files from unix to windows and vice-versa?

please if you have any idea.

thanks

You can store the password in encrypted format in some file and use it in your script. Of course decrypt before you pass the password to ftp script :slight_smile:

Here is how I use ftp to send files from unix to windows.
You can store password/username in a file, instead of having it in the script.

HOST='remote.server.com'
USER='remote'
PASSWD='rpassword'
DATE=$(/bin/date +%Y%m%d)
TIME=$(/bin/date +%H)
HOSTNAME=$(/bin/hostname)

tar zcvfP $DATE.$TIME.$HOSTNAME.tar.gz  /var/bin/*.sh /etc/munin/plugins/* > /dev/null &&
ncftpput -E -u $USER -p $PASSWD $HOST / $DATE.$TIME.$HOSTNAME.tar.gz ;:

rm $(date +%Y%m%d).$(date +%H).$HOSTNAME.tar.gz

tar zcvfP $DATE.$TIME.$HOSTNAME.tar.gz /var/bin/.sh /etc/munin/plugins/ > /dev/null &&
ncftpput -E -u $USER -p $PASSWD $HOST / $DATE.$TIME.$HOSTNAME.tar.gz ;:

what does this mean?

Those are some example commands and nothing in perticular..

You don't say what Unix distro you are using but there is a 'standard' method of doing this which is to use .netrc

If ftp is launched with a target nodename but no credentials then, in addition to looking up the target ip address in /etc/hosts, it will also look for a file .netrc in the home directory of the user under which it is running. It will look in there to see if the target nodename is listed and, if so, will use the userid and passwd given to make the connection. This completely automates the ftp connection (you can even test it interactively). With regards to your security concerns (understanding that ftp is insecure from a networking point of view) the .netrc file must have access rights for that specific account only in order for it to work (the way is way designed) so any other user on Unix could not gain access to the Windows password. Additionally, even better, the account calling ftp need not be an interactive login at all; could just be used by cron.

Try a searching the Unix.com forum for ".netrc" and also Google search for your distro + .netrc

Hope that helps.

Script:

tar zcvfP $DATE.$TIME.$HOSTNAME.tar.gz  /var/bin/*.sh /etc/munin/plugins/* > /dev/null &&
ncftpput -E -u $USER -p $PASSWD $HOST / $DATE.$TIME.$HOSTNAME.tar.gz ;:

Replace all variable with data=

tar zcvfP 20130503.12.server1.tar.gz  /var/bin/*.sh /etc/munin/plugins/* > /dev/null &&
ncftpput -E -u remote -p rpassword remote.server.com / 20130503.12.server1.tar.gz ;:

Translated to english:
Zip all script files *.sh from folder /var/bin and all files from folder /etc/munin/plugins to a tar file name 20130503.12.server1.tar.gz
This tar file has its name as date , time and server name

Then use ncftpput (and ftp program) to send it to server remote.server.com , using username= remote and password= rpassword