Connecting to remote servers

Please advise,

The previous thread asked about the automated transfer of files between two servers. The question is - is there any way of encrypting the password within the script or is it a matter of setting the permissions settings on the script so that it can only be executed and possibly not read. Does the etc/hosts file come into play when setting up such connections?

Previous solution - note the username and password are visable

You may modify few of lines before running.

#!/bin/ksh

#Modify these three lines
USER=your_login_name
PASS=your_password
HOST=THE_DESTINATION_IP
FTPLOG=LOG_FOR_YOUR_REFERENCE

ftp -ivn << EOF > $FTPLOG 2>&1
open $HOST
user $USER $PASS
#If the file is binary, change it from 'asc' to 'bi'
asc
#Modify this line
cd /DESTINATION_PATH
put fbdemo.dat
bye
EOF

Then you can put this script in crontab for auto run. I will give you another post for interactive because you may think that it has a security issue on password shown in a script.

The file .netrc is an ASCII file containing login and initialization information used by the ftp auto-login process (so don't use ftp -n as this will disable auto-login). This file resides in the home directory of the user. It must be read/writable to the user only (ie. chmod 600) or it will be ignored. It has the format of...

machine hostname user name password string

See the ftp man page for further information.