The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Advanced & Expert Users
.
google unix.com



UNIX for Advanced & Expert Users Expert-to-Expert. Learn advanced UNIX, UNIX commands, Linux, Operating Systems, System Administration, Programming, Shell, Shell Scripts, Solaris, Linux, HP-UX, AIX, OS X, BSD.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Can a script runned in local server access remote server? luna_soleil Shell Programming and Scripting 3 02-26-2009 05:38 PM
script to change the access permissions of the files smartgupta Shell Programming and Scripting 3 01-13-2009 10:44 AM
How to uncompress zip files in a remote server from a script rahul26 Shell Programming and Scripting 2 06-02-2006 02:14 PM
Remote Access chrs0302 SUN Solaris 2 09-21-2005 03:30 PM
Need help to access/mount so to access folder/files on a Remote System using Linux OS S.Vishwanath UNIX for Dummies Questions & Answers 2 07-30-2001 09:17 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-28-2009
twk twk is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 15
Help with Script to Access Remote Files

I need to access files on remote servers and need to do this in a script because there are 100's of servers and 1000's of files.

I've tried

ssh user@host 'ls -l /dir path/fileName'

but cannot figure out how to deal with the prompt for password (here document is of no help). I've read of a way to setup the local and remote hosts to permit ssh command to execute with out password but that is not a viable option in this case.

Any suggestion on how to get a password into ssh or perhaps another method of accessing the file information appreciated.

Thanks for your consideration... tw
  #2 (permalink)  
Old 08-28-2009
cfajohnson's Avatar
cfajohnson cfajohnson is offline Forum Advisor  
Shell programmer, author
  
 

Join Date: Mar 2007
Location: Toronto, Canada
Posts: 2,380
Quote:
Originally Posted by twk View Post
I need to access files on remote servers and need to do this in a script because there are 100's of servers and 1000's of files.

I've tried

ssh user@host 'ls -l /dir path/fileName'

but cannot figure out how to deal with the prompt for password (here document is of no help). I've read of a way to setup the local and remote hosts to permit ssh command to execute with out password but that is not a viable option in this case.

Any suggestion on how to get a password into ssh or perhaps another method of accessing the file information appreciated.

On the local machine:


Code:
ssh-keygen rsa

Then copy the contents of $HOME/.ssh/id_rsa.pub to $HOME/.ssh/authorized_keys on the remote machine.

Make sure that only you can read the directory .ssh and the files it contains on both local and remote machines.

You should now be able to ssh to the remote machine without needing a password.
  #3 (permalink)  
Old 08-28-2009
twk twk is offline
Registered User
  
 

Join Date: Aug 2009
Posts: 15
Thanks but that is not a practical solution since there are somewhere around 600 servers and the list of servers changes frequently. I'm thinking the way to go is with an expect script and am trying to see if I can get that to work for me.

I will likely use your suggestion in other applications and do appreciate it. Thanks.
Reply

Bookmarks

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 12:41 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