Solved

SFTP

Posted on 2012-03-22
3
563 Views
Last Modified: 2012-04-09
Hello,
  I would like to know how to pass a password for a sftp routine,

I am sending a file using sftp and need to send the password.  The $PASS does not work and I am not sure how this is done.  When I run my script, it asks for a password that I need to type for the script to continue.  Thanks.

ftp_the_file()
{
sftp -oport=22 $USER@$NODE 2>$ftp_message_file 1>&2 <<EOF
$PASS
cd $DIRECTORY
get $NEW_FILE $NEW_FILE
rm $NEW_FILE
bye
EOF
}
0
Comment
Question by:bje
3 Comments
 
LVL 1

Expert Comment

by:DrMadAxe
ID: 37755295
maybe another script to post to that form? IDK What are you trying to do ultimately? upload a file securely or send a form securely?
0
 

Author Comment

by:bje
ID: 37758718
upload a file securely
0
 
LVL 6

Accepted Solution

by:
eksatx earned 500 total points
ID: 37759400
I recommend using sshpass.

sshpass -e sftp -oBatchMode=no -b -p 'my_password' - my_user_name@server_url << !
   put file_to_upload
   bye
!

Open in new window


Here is an article with some more info on sshpass: http://www.cyberciti.biz/faq/noninteractive-shell-script-ssh-password-provider/
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question