Help with Script to Access Remote Files


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Help with Script to Access Remote Files
# 1  
Old 08-28-2009
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  
Old 08-28-2009
Quote:
Originally Posted by twk
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  
Old 08-28-2009
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.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Except script to run a local shell script on remote server using root access

local script: cat > first.sh cd /tmp echo $PWD echo `whoami` cd /tmp/123 tar -cvf 789.tar 456 sleep 10 except script: cat > first #!/usr/bin/expect set ip 10.5.15.20 set user "xyz123" set password "123456" set script first.sh spawn sh -c "ssh $user@$ip bash < $script" (1 Reply)
Discussion started by: Aditya Avanth
1 Replies

2. Shell Programming and Scripting

Script connect to remote server, not find files and exit only from remote server, but not from scrip

I have a script, which connecting to remote server and first checks, if the files are there by timestamp. If not I want the script exit without error. Below is a code TARFILE=${NAME}.tar TARGZFILE=${NAME}.tar.gz ssh ${DESTSERVNAME} 'cd /export/home/iciprod/download/let/monthly;... (3 Replies)
Discussion started by: digioleg54
3 Replies

3. Shell Programming and Scripting

Do I require remote login access to a windows server to transfer files from a UNIX server

Hi All I need to transfer a file from a UNIX server to a windows server. I saw that it is possible to do this using scp command by looking at the forum listed below: ... (2 Replies)
Discussion started by: vx04
2 Replies

4. Homework & Coursework Questions

Remote Access vs Local Access

Dear Friends, This is not a problem , it's a course work (UNIX scenario).... As part of it I am searching Remote Attacks and find points as 1. Exploiting a listening service 2. Routing through Unix system that is providing security between 2 or more networks 3. User initiated Remote execution... (1 Reply)
Discussion started by: anespa
1 Replies

5. UNIX for Dummies Questions & Answers

kernel giving access for multiple users to access files

hi all, i want to know y kernel is giving access for multiple users to access a file when one user may be the owner is executing that file. Because other user can manipulate that file when the other user is executing that file, it will give the unexpected result to owner . plz help me... (1 Reply)
Discussion started by: jimmyuk
1 Replies

6. Shell Programming and Scripting

Can a script runned in local server access remote server?

Hi, Im creating a script that is supposed to run commands on remote server using sftp. My script is as below: #!/bin/ksh sftp remote_server mypassword cd /u08/mydir/allfiles mget * .. But this is what I got when I runned the script: Connecting to remote server...... (3 Replies)
Discussion started by: luna_soleil
3 Replies

7. Shell Programming and Scripting

script to change the access permissions of the files

Hi, I want to change the access permissions of the files whose extension is same.For example *.c but these are inside a directory and inside that other directory is there and it contains the .c files..for example-- So my aim is to search the files under src and change the access permissions... (3 Replies)
Discussion started by: smartgupta
3 Replies

8. Solaris

Remote Access

Hi We access all our SPARC/x86 servers (Solaris 8,9 & 10) using ssh. I am looking for a open source tool that allows me to get the GUI on to my laptop. I tried with x-org and some other applications like Hummingbird. Encountered problems with license issues and CPU compatability of my laptop. ... (2 Replies)
Discussion started by: chrs0302
2 Replies

9. UNIX for Dummies Questions & Answers

Need help to access/mount so to access folder/files on a Remote System using Linux OS

Hi I need to access files from a specific folder of a Linux system from an another Linux System Remotely. I know how to, Export a folder on One SCO System & can access the same by using Import via., NFS in the Sco Unix SVR4 System using the scoadmin utility. Also, I know to use mount -t ... (2 Replies)
Discussion started by: S.Vishwanath
2 Replies
Login or Register to Ask a Question