Since the server is not yet ready for me to play around with, and I don’t know how to setup public/private key pair, the only way I can opt for is SSHPASS command. I think this should be the cheapest solution I could opt for. I do understand that SSHPASS is insecure and not encourage to use, but this should be fine under development stage.
Assuming I’m going to transfer a file to a destiny location at /home/theuser with username theuser and IP 220.127.116.11. With SFTP, this is what I’ll do in the script:
sftp email@example.com:/home/theuser << EOF put thefile.txt bye EOFWhenever this script is run, I’ll get a prompt for password then only the process will continue. Now if I do it with SSHPASS command, this is how it look like:
sshpass –p ‘password’ sftp firstname.lastname@example.org:/home/theuser << EOF put thefile.txt bye EOFThere is also an alternate solution as shown below, by keeping the password in environment variable but which is strongly not a good way to go.
export SSHPASS=password sshpass –e sftp email@example.com:/home/theuser << EOF put thefile.txt bye EOF