How to automate sftp without using expect script?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to automate sftp without using expect script?
# 1  
Old 06-25-2010
How to automate sftp without using expect script?

How to automate sftp with out using expect script?



My batch file has the password but it is not taking. Please see below.

I want to use this sftp connection in a loop for pushing new files in a directory one at a time. Hence I can not use an expect script.



Code:
bash-2.05$ /usr/bin/sftp -b /tmp/Cap_batch username@89.202.125.15
Connecting to 89.202.125.15...
username@89.202.125.15's password:

bash-2.05$ more /tmp/Cap_batch
@passwd!


It would be great if some body can suggest a possible solution.
# 2  
Old 06-25-2010
You'll have to set up key authentication so you will be able to use a here-script for automation.
sftp does not work with feeding a password in a script. That's unsecure and that's why keys should be used.
If possible and key authentication is set up, maybe use scp instead of sftp. Might be more comfortable than using a here-script.

For how to set up a passwordless key based communication with ssh/scp/sftp search this forum or the web, there are plenty of guides.
Don't forget to enter no password when creating the key pair with ssh-keygen.
# 3  
Old 06-25-2010
Thanks Zaxxon for the prompt reply.

But sftp connection is enabled between a client site. Hence ssh key can not be implemented... :-( any other solution...??
# 4  
Old 06-25-2010
Hint: SFTP is but a sub-system of SSH...
# 5  
Old 06-28-2010
Oh Sorry for the confused reply..! I know that... What I meant is, I can't exchange the ssh keys to the client for some reasons. Any other solutions?
# 6  
Old 06-28-2010
Talk to the client, and ask them what they would prefer:
  • Get a public key from you, and implement it so that you can authenticate yourself with it
  • Have the password for their service passed from an expect script where it's possibly easy for everyone to read
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Automate sftp process using script

Hi, guys, I am trying to automate a sftp process using "expect" method (since the key authentication method is disabled in my company network, there is no helping it). In order to try, I type in the command manually: sftp @ > << EOF >cd >ls -l >EOF >Connecting to @servername password: ... (3 Replies)
Discussion started by: warmboy610
3 Replies

2. Shell Programming and Scripting

SFTP script to automate login in to remote server

Greetings, guys. I'm not much of a programmer forgive me for being a noob, because of someone leaving, I was put in an IT spot where I have to figure out a few things. Being new to Linux and programming has been a challenge. My boss has asked me to create an automated script to connect to a 3rd... (7 Replies)
Discussion started by: giovannym
7 Replies

3. Shell Programming and Scripting

Expect Script for SFTP Upload

I am attempting to utilize an expect script (that is called from a parent bash script) to perform a file transfer over sftp. The script works except I cannot catch timeouts. I need to be able to tell in the parent bash script when the expect script has timed out, or completed successfully. It... (3 Replies)
Discussion started by: thaller
3 Replies

4. Shell Programming and Scripting

Using expect to automate sftp

I am trying to use a for loop in my expect cmdFile that I am calling. I want to be able to call either one file name or a series of file names in the working directory (that I won't know the names before hand) and then pass the names to the sftp program. Something like for i in (ls *txt) do (0 Replies)
Discussion started by: vedder191
0 Replies

5. Shell Programming and Scripting

Expect script to automate telnet session

Hi all, I am currently running a daemon which creates a virtual terminal for testing purposes. Essentially, if I were to interact with it manually, this is what I get. john@test1:~$telnet localhost 7777 Trying ::1... Connected to localhost. Escape character is '^]' mip6d> pl eth2... (6 Replies)
Discussion started by: abxccd
6 Replies

6. Shell Programming and Scripting

Expect Script to Automate SSH

How would I write an expect script to automate ssh and what file extention do expect files use? (11 Replies)
Discussion started by: Prodiga1
11 Replies

7. Shell Programming and Scripting

How to automate sftp in a script to 'get' files.

Hi, I read a couple of forum entries about scripting sftp using the '-b' option, but in my case it still prompts for the password. Does anyone have a sample script for an sftp block to 'get' files from the remote server without prompting for a password? Both the remote and the local servers... (1 Reply)
Discussion started by: ChicagoBlues
1 Replies

8. Solaris

Issue with Expect Script for SFTP.

Hi Experts, I am learning expect and wrote the below script for automatic sftp into a server: #!/usr/local/bin/expect -f -d spawn sftp -v test@mumux503 # logs into mumux503 as test user expect "password:" sleep 20 send "test\r"; # sending the password for test... (3 Replies)
Discussion started by: Hari_Ganesh
3 Replies

9. Shell Programming and Scripting

Help with Expect SFTP script

Hi All, Here is my Expect script, I don't get any error message when I run it. But the file never goes to other system? I also paste the output screen below. When I run the script, the script runs so fast. But when I do it manually, it takes about 10 minutes for the file to transfer. ... (1 Reply)
Discussion started by: samnyc
1 Replies

10. Shell Programming and Scripting

automate sftp using unix script

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... (34 Replies)
Discussion started by: priyamurthy2005
34 Replies
Login or Register to Ask a Question