Program that logs in on remote computer via ssh and executes commands on it
I am a network administrator and i want to write a program that can log in on remote computers via ssh and then execute certain commands on it.
What i want to know is: 1. how to make the program log in. 2. how to execute the commands. |
Simple.
First configure a public/private key pair for passwordless ssh-logins. This is what you need before you can write unattended scripts. Look at these google hits, the process is well-documented: ssh private key setup Once you have a key - assume that the key for your remote ssh server is "/home/alien/.ssh/myremoteserver" - you use a "here-document" to run the remote commands: Code:
ssh -i "/home/alien/.ssh/myremoteserver" -l alien some.remote.net <<EOT Code:
rsync -va -e "ssh -i /home/alien/.ssh/myremoteserver -l alien" some.remote.net:mydailybackup_20070908.tar.gz . |
not a networking question. moved to Linux - software. additionally you might like to look at a tool like dsh which allows you do do as above to multiple systems at once.
|
All times are GMT -5. The time now is 08:39 AM. |