The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Script(s) to Automate Tasks droppedonjapan Shell Programming and Scripting 2 05-21-2008 10:32 AM
script to automate mksysb via nim in AIX 5.3 barkath Shell Programming and Scripting 0 12-20-2007 06:46 PM
here document to automate perl script that call script hogger84 Shell Programming and Scripting 3 10-22-2007 10:15 AM
Automate batchfile generation for sFTP mpang_ Shell Programming and Scripting 0 04-26-2006 05:34 AM
automate the input in a script erwinspeybroeck UNIX for Dummies Questions & Answers 11 01-31-2002 10:54 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-15-2005
csaunders csaunders is offline
Registered User
  
 

Join Date: Sep 2003
Location: Arlington, VA
Posts: 160
Quote:
Originally Posted by dangral
I think you have two issues here:

1) Achieving passwordless authentication
2) automating sftp

I will try to discuss one at a time. Forgetting about sftp for a second, in order to achieve passwordless authentication ( in your terms non-interactive authentication) you need to set up a key that does not have a password. See this link for tips on how to set that up.

However, please see this warning and tips on how to set it up to be secure. (Sorry for all the links)

Once you have verified passwordless authetication is working, you can now attempt to automate sftp. What the link in my previous post said is:


You would not be putting a password file after sftp -b, you would be putting your standard-in device or a file with all the ftp commands. So on solaris, your script might look like this:

Code:
  
  #!/bin/sh
  echo "OK, starting now..."
  sftp -b /dev/fd/0 remotehost <<EOF
  cd pub
  ascii
  get filename.txt
  bye
  EOF
the link you have given does not work, tried the steps on solaris 9 and it still asks for password....
  #2 (permalink)  
Old 12-12-2005
Phantom_Phixer Phantom_Phixer is offline
Registered User
  
 

Join Date: Dec 2005
Location: New Jersey
Posts: 2
I am looking for a script that will allow me to automate file transfer via 'sftp'. key-gen is not an option as the 'client' (where we are 'getting' the files from) will mot permit us to generate the public/provate' keys for scp.
I have tried a number of examples shown and none of them work with sftp Each one either balks at the password or prompts for the password. Can someone show me a way to do this? Thanks.
  #3 (permalink)  
Old 06-15-2005
STiVo STiVo is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 5
Well if you can get the user keys working that will make things much easier.

Also, why don't you just use scp instead? Or maybe curl?

Something like this...
Code:
#!/bin/sh

scp remoteuser@remotehost:/path/to/file.txt /path/to/local/target
With the user keys setup you wouldn't have to interact with it at all- but remember it's a lot harder to get a password from my head than from my .ssh folder...

Last edited by STiVo; 06-15-2005 at 03:25 PM..
  #4 (permalink)  
Old 07-29-2005
cyg cyg is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 1
use expect

using expect can get around the password verification issue.

Code:
/usr/local/bin/expect <<EOF
spawn  /usr/local/bin/sftp user@remotehost
expect "password:"
send "cd pub \r"
expect "sftp> "
send "ascii \r"
expect "sftp> "
send "get filename.txt \r"
expect "sftp> "
send "bye \r"
EOF
  #5 (permalink)  
Old 01-25-2006
LindaM LindaM is offline
Registered User
  
 

Join Date: Jan 2006
Posts: 1
Quote:
Originally Posted by priyamurthy2005
Hi All,
I need to write a UNIX script that automates the sftp process. I should be able to do a sftp to a secure box and get a file from there. I am having a problem doing this because no matter what I do, when I run my script, I get a prompt at command line asking for a password. How could I automate this? Could someone give me a sample script?
Thanks in advance.
Priya
DID YOU EVER GET THIS TO WORK??
  #6 (permalink)  
Old 05-08-2006
Vikas Sood Vikas Sood is offline
Registered User
  
 

Join Date: May 2006
Posts: 32
automating sftp

All,

This is a great forum for beginners like me. I have been following this thread in its multiple forms on various websites. I got a good start by following this thread but got stuck after doing exactly what has been mentioned in this thread word by word. The pain area : it was still prompting me for a password everytime.

Then, somebody suggested to recreate $HOME/.ssh directory again from scratch. Guess what, i did that and now i am able to log on from one server to another without being prompted for a password.

I dont know how much this information is gonna be useful to ppl but sure proved the definite solution for me and i thought i probably should share it with everybody.

Regards
Vikas.
  #7 (permalink)  
Old 07-28-2006
unxuser unxuser is offline
Registered User
  
 

Join Date: Jul 2006
Posts: 4
Re

Hi Vikas,

Would you please give us more details what mothed you used get around? Thanks.
Closed Thread

Bookmarks

Tags
linux, linux commands, mtime, sftp script, solaris

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:36 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0