user7268185 user7268185 - 4 years ago 138
Bash Question

how to fetch data from a unix server to another server in unix?

There are two unix servers called HYD13 and HYD25.

I am having a script(in my home dir) in HYD13 which fetches the required data from that server(HYD13) only and all the required data are printed in a text file.

But my requirement is I need to configure the same script in HYD25(in a path) and It will fetch the data from HYD13 server and prints the data in HYD25 server(mentioned path). But the issue is how to connect HYD13 sever from HYD25 inside the script ?

Could you please help me on this ?

Answer Source

You'd usually use something like scp or rsync, depending on how much data you have to move. scp can move files and directories, while rsync is good when you need to sync and update directories.

Both talk over ssh, so to avoid having to type in your password over and over again (or worse, hard code it into the script) be sure to use ssh keys and an ssh-agent. This lets you log into servers without needing to type in your password, instead the stored keys are used, and all that is tied to logging into your account. Github has a good tutorial on creating keys and adding them to an ssh-agent. Ubuntu also has a good tutorial which covers ssh in more detail and how to put the key on the remote machine.

Finally, rather than having to put your private keys on HYD13 and HYD25, you can leave those keys on one machine and use ssh key fowarding to use those credentials when you log into HYD13 or HYD25. Again, Github has a nice tutorial on how to do this.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download