You cannot pass password to sftp or scp. You should use public key authentication for purpose.
Main Topics
Browse All TopicsHi,
I have an scenario to sftp the files using Admin Id (user--> mhvsftp). But there are 5 other users (call it as 'businessuser1, businessuser2, etc.'). User "businessuser1" can able to login through his id and will execute the sftp script using mhvsftp. (FYI, using 'mhvsftp' user the key pair is generated and shared with external vendor External.ftp.com).
I have tried to acheive the same by the following method.
Step 1: Created a ".externalvendor_sftp" file using user mhvsftp.
Step2 : Edited teh file ".externalvendor_sftp" to have the following
FTPSTRING=External.ftp.com
USERNAME=mhvsftp
PASSWORD='happy$1
Step3: Inside my sftp script i have entered the following to execute through mhvsftp user (even thoug i executes through businessuser1)
ENVFILE=/mhvsftp/home/.ext
. $ENVFILE
sftp $FTPSTRING user $USERNAME using $PASSWORD
Please let me know the sftp option to acheive this.
This question is in progress.
Our experts are working on an answer right now.
Sign up for immediate access to the solution once it becomes available.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I think you need to either use scp where you need to set trust between the two systems / accounts (see links below for setting trust or no password), or use sftp along with expect (please see link for sftp and expect)
no password links:
http://waelchatila.com/200
http://www.cvrti.utah.edu/
http://www.linuxjournal.co
expect and sftp link
http://www.experts-exchang
Each of your business user on system one have to create the private/public key pair by running the command "ssh-keygen -t rsa -b 1024". If you are the admin on this system you can do this for each of these users. This creates 2 files id_rsa and id_rsa.pub in a directory ~/.ssh , you as admin can then transfer these id_rsa.pub files to the other system, and you can change the name to businessuser1.pub, bussinessuser2.pub, etc. On this other system you also run the rsa-keygan -t rsa -b 1024, but as the user the businessuser1 and businessuser2 are going to transfer to. You go to the ~./.ssh directory of your destiantion system now. There you have the 2 files id_rsa.pub and id_rsa and all the businessuser1.pub, businessuser2.pub etc. You need to create the authorized_keys file from concatenating all the businessuserxx.pub. Do this by "cat business*.pub >>authorized_keys". Now all the businessusers can transfer files to this destination without using password. You can test it by logging in via ssh without password. Make shure your destination server has a ssh server running.
Business Accounts
Answer for Membership
by: omarfaridPosted on 2009-02-06 at 11:00:48ID: 23572917
which unix platform are you using? I am not sure if sftp supports passing username and password as you described