I need create a Shell script to do the SFTP process. How can i provide username and password in the script.I had the below code.But it ask for password.How can i add user name and password in this code
echo "OK, starting now..."
sftp -b /dev/fd/0 testwasds3l<<EOF
cd /opt/isproj/VOM/Scripts
ascii
put /opt/isproj/VOM/Scripts/jzkvm15028_Truncate_SP_Exec
bye
EOF
You can put a unique username for each host you access in your ~/.ssh/config.
For example:
Host testwasds3l
User morbid_angel
And to not have to use a password, copy your ~/.ssh/id_dsa.pub file (which contains one very long line) to the other host in file ~/.ssh/authorized_keys. Append it to the end if it exists or create it. Make sure to set the file permissions to 600 so only you can read it.
Then if you install the keychain software package you can be prompted once for your key passphrase on the first boot after login and have automatic passwordless access to the other machine. Security is provided by the requirement to login to the first machine.