Solved

SFTP

Posted on 2012-03-22
3
565 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Support for Notepad++ (including downloading & installing a plugin) 5 205
ejb example issues 3 56
ejb message driven bean mdb creation steps 2 37
Why use this lambda? 12 67
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.

730 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