LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-19-2009, 03:33 PM   #1
iamakshay
LQ Newbie
 
Registered: Oct 2009
Posts: 1

Rep: Reputation: 0
SFTP without password and without public/ private key


Hi,

I am new to the whole linux scripting word but I have requirement where I have to write small script for doing SFTP without using public/ private key.

I tried following script but expect is not working. can some one help me with this.

#!/bin/sh
#!/usr/local/bin/expect

echo "Starting"
expect "password:"
sftp -b batchfile$1@$2 <<EOF
send "A4zNC3mZHv](\n"
cd $3
put $4
bye
EOF

Thanks,
Akshay
 
Old 10-19-2009, 04:28 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984Reputation: 1984
well you're waiting for a password prompt *before* you've run the sftp program.. how is that meant to work?? also sftp isn't a valid expect command. You need to run stp via the spawn directive, not directly.

try looking at some examples, e.g. http://www.wellho.net/forum/The-Tcl-...ng-expect.html
 
Old 10-19-2009, 04:35 PM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by iamakshay View Post
I have requirement where I have to write small script for doing SFTP without using public/ private key.
Also what is the reason for doing that? SFTP is not meant to be used like that. Can't you use ssh-agent to set up keys? Besides hardcoding passwords or passphrases is not a scripting or usage best practice.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Public/Private Key Pairs Kissell Linux - Security 3 01-24-2009 04:36 AM
Public key, private key explained calande Linux - Security 3 06-12-2008 05:23 AM
Private/Public key vs. Password authentication w/ SSH MykeV Linux - Security 5 11-25-2007 11:49 AM
need help with SSH private/public key taduser Linux - Security 2 04-02-2007 07:07 PM
RSA public key encryption/private key decription koningshoed Linux - Security 1 08-08-2002 07:25 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration