[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How to SSH FTP files through cron job from Solaris box to a Windows NT/2000 box

Posted on 2003-12-04
7
Medium Priority
?
4,406 Views
Last Modified: 2013-12-21
Hello all!

I need to use SSH in a shell script invoked from a cron job that is scheduled to run on daily basis.  

I have a Solaris boxes that is required to run a cron job, which will execute a shell script on daily basis. This shell script needs to contain the code to run SSH, which will connect to a Windows box and transfer dynamically generated files from my Solaris box to the windows box.

I am then prompted for a password of the user@windows box, which I supply, and the command executes perfectly.

SOURCE="testfile.txt"
DEST="<user>@<ip_of_windows_box>:c:/test"
scp -d -p "$SOURCE" "$DEST"

I need to create a shell script that will run a SSH, the password prompt has to be by passed since the password may be changed from time to time.

I am not an expert in UNIX/SOLARIS, just know the basic commands of unix.

I wld require the examples for cron job, SHH FTP script and the settings on SOLARIS & WINDOWS boxes

Can anyone help me in this regard

Thanks in advance
0
Comment
Question by:pradeepbkumar
[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
7 Comments
 
LVL 18

Accepted Solution

by:
liddler earned 252 total points
ID: 9873679
crontab -e
to edit your cron
add the line
0 9 * * * /path/to/script
This will run your script at 9:00 am
then your script will be
#!/bin/ksh
SOURCE="testfile.txt"
DEST="<user>@<ip_of_windows_box>:c:/test"
scp -p "$SOURCE" "$DEST"


Make sure you make your script executeable (chmod +x /path/to/script)
That should work.  However instead of using passwords I wolud consider using a secure key exchange ( do a man ssh-keygen), where you create a key on the source machine and copy it to an authorized_keys file on the destination machine, then you won't need to use a password.
0
 
LVL 38

Assisted Solution

by:yuzh
yuzh earned 248 total points
ID: 9874061
You need to use "expect" script to handle the password, you can download
expect from:
http://www.sunfreeware.com/

if you don't know how to write an expect script, you can use autoexpect to create
one for you.

man autoexpect
to learn more

Or
setup ssh without password

You can do a search at EE "ssh without password"
or "expect password"

you will find a lot of examples.

0
 

Author Comment

by:pradeepbkumar
ID: 9875094
Hi all pls feel free to ask queries,

I need the full solution / explanation as mentioned in my query stated

"I wld require the examples for cron job, SHH FTP script and the settings on SOLARIS & WINDOWS boxes"

have already tried out the keygen method but still getting a password prompt ---- let me know wht the SOLARIS & WINDOWS boxes must be installed with?

as of now I have

ON SOLARIS

bash-2.03# ssh2 -V
ssh2: SSH Secure Shell 3.2.9 on sparc-sun-solaris2.6
Product: SSH Secure Shell for Servers
License type: evaluation
Code: 25010-32X00
bash-2.03#

ON WINDOWS 2000

bitvise's winsshd (does this needs a change?)
0
 
LVL 14

Expert Comment

by:chris_calabrese
ID: 9875124
Instead of supplying the password, why not make use of SSH's abiltity to do passwordless authentication using public-key crypto. Much more secure and much easier.

See the documentation for your particular SSH flavors in order to generate keys on the solaris box and set them up to be used on the windows box.
0
 
LVL 1

Expert Comment

by:fl_kiwi
ID: 10160810
When you setup the public key authentication using ssh-keygen be sure to specify a null pass phrase.  This is what will allow you to do it without a password.  Its pretty easy, but may seem complicated the first time, when you have to copy you public key to the remote host.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Hello fellow BSD lovers, I've created a patch process for patching openjdk6 for BSD (FreeBSD specifically), although I tried to keep all BSD versions in mind when creating my patch. Welcome to OpenJDK6 on BSD First let me start with a little …
Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
Suggested Courses

656 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