|
From a script on server1, you can run "ssh [user]@server2 [command]" and whatever is in [command] will execute on server2 as user [user].
You will be prompted for a password unless you set up public keys, which basically involves:
(Presume user running script on server1 is "fred" and logs in as "bob" on server2 to run commands listed in fred's script on server1.)
Run "ssh-keygen -t dsa" as whatever user uid the script will run from on server1 (fred). Press [enter] when prompted for passphrase (twice).
Copy ~fred/.ssh/.id_dsa.pub to ~bob/.shh/authorized_keys on server2.
Run "ssh server2 date" from fred's shell on server1 to confirm that you can log in as bob on server2 via ssh without a password. The first time you might have to reply with "yes" so that's another reason to test manually first.
If login fails (if it asks for a password) you might have to change permissions on ~bob/.ssh* on server2 to whatever the sshd server requires. Checks logs to confirm this.
|