![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| 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 |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
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 automate this? Could someone give me a sample script? Thanks in advance. Priya |
|
||||
|
This has been answered before in the forums here.
If you don't want to specify a password you need to generate a passwordless key with ssh-keygen and then copy the public key to the target host's ~/.ssh/authorized_keys file. This also has been discussed here before. Try a search. |
|
||||
|
Thank you so much dangral. I looked at your reply and looked at the sites you suggested. I am still at a loss. It asks me to use ssh. I tried that and created a public key file. Now it asks me for passphrase for public key file. I do not want any interactive mode at all. I somehow want it to automatically take the password for a file or something. I tried the following:
sftp -b passwordfile username@IP The file "passwordfile" has passowrd stored in it. Still, it does not work. It first asks me for password interactively and only after I typed the password, it will execute the "passwordfile". I looked on help for sftp and I was told that if I use non-interactive authentication, only then the above statement will work, meaning, it will take password for the batch file. My question now is that: how do I achieve non-interactive authentication? Thanks in advance. |
|
||||
|
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: Quote:
Code:
#!/bin/sh echo "OK, starting now..." sftp -b /dev/fd/0 remotehost <<EOF cd pub ascii get filename.txt bye EOF Last edited by dangral; 04-01-2005 at 01:00 PM.. Reason: added security warning |
|
|||||
|
Quote:
Hi, When I tried to use the snippet of your code, I am unable to connect. the -b option used by you is not viable in solaris. here it stands for buffersize. > sftp -h Usage: sftp2 [-D debug_level_spec] [-B batchfile] [-S path] [-h] [-V] [-P port] [-b buffer_size] [-N max_requests] [-c cipher] [-m mac] [-4] [-6] [-o option_to_ssh2] [user@]host[#port] > sftp -V sftp: F-Secure SSH 3.1.0 (build 12) on sparc-sun-solaris2.8 > Thanks Rishi |
|
||||
|
You are using F-Secure sftp. The version I was referring to is OpenSSH.
Try using -B instead of -b. |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Tags |
| linux, linux commands, mtime, sftp script, solaris |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|