Switching server in UNIX via shell script (SSH )

Requirement: I am writing a shell script which take some file from say Server1 and I have to execute some command on Server2 then I have to manipulate the data and based on that I have to produce report.
Problem:I can schedule the shell script on only one server (Server1 or Server2) So, In the shell script itself I have to switch the server . If I will switch the server then it will prompt for the password. I don't want that as it will be scheduled(No one will be there to enter the password)

Please suggest me the way to hardcode the password or switch the server without password.

(I have no right to install anything on server )

Welcome raks2301,

Thanks for an interesting question :wink:

If you plan to switch the server within your script, how would you plan to do it? Would it be rsh/resh/remsh, ssh or something else? These can be set up to act without a password for scheduled work without the need to install anything else.

It would be good to know the OS of each server, so the output of uname -a would help there.

I'm assuming that you would you need to pass data between the servers as well as generate a report. Can you elaborate how to are set up, how you drive your schedule and what you use to move/copy data. There are various options we can explore.

What have you tried so far, and where do you get stuck?

Please post code, files, input & output/errors in CODE tags as it makes them easier to read and preserves multiple spaces for indenting and fixed width data.

Thanks, in advance,
Robin

1 Like

Thanks for the reply !!
Here are the answers for the questions
I am using ksh...
uname is AIX

ssh and scp commands works.
I tried both the commands to copy the file but everytime it asks for the password.
I tried the passphrase method , everything was executed successfully but when switching It asks for password.

I am reading a file(created daily ) from on server and based on that I am extracting some strings ... Then I have to read file from other server also and extract string from there also ... Then I have to send email via unix (scheduled email) , For this I want my code to be scheduled in such a way that autogenetrated email should be sent on daily basis after reading file from both of the server.

Searching a bit our forum you would have found e.g.

look how to configure for passwordless ...