Hello all,
I've just joined. I did a google search and your site came up,
I had a look and thought I'd like to become a member.
I'm from Ireland.
I've written a few scripts before, but this new task has me foxed.
I would like to figure out the best approach to achieving the following
A single script that does the following
login to machine a (I typically use putty to do this)
login to machine b (as above)
on machine_a run a command such as "service xxx stop; service xxx start"
on machine_a ps -ef | grep AppName to confirm the app started right
on machine_a run top, and grep for a process by name, and batch the cpu% usage result to a file ( I can do this already)
on machine_b cd to a specific directory
on machine_b run a script that points at machine_a
on machine_b, when the script finishes
machine_a will parse the result file, and confirm the average of the cpu% is less than a threshold
That's pretty much it.
The hard part I suppose would be the single script spawing scripts on two different machines and synchonising them?
# ssh-keygen -b 2048 dsa # This generates your key-pair
# Enter to save to /home/sroot/.ssh/id_dsa
# Enter passphrase (empty for no passphrase): Enter
# Saved in /home/sroot/.ssh/id_dsa.pub
# ssh remoteHost
# mkdir ~/.ssh
# chmod 0700 ~/.ssh
# Paste the contents of (local) ~/.ssh/id_rsa.pub into (remote) ~/.ssh/authorized_keys
Logout and try again to log in. If it doesn't ask for a password, you're all set
I couldn't ssh to the remote machine, so I used a putty I had open already
It wouldn't let me in without a password.
Maybe it's because on the remote it's root, and the local is sroot?
Should not be the problem, as long as the target machine has the authorized_keys correctly corresponding with the .pub on the local one. Just make sure that though you are sroot here, you are ssh'ing to root there.