hi,
I have a script abc in a machine xyz. which i can access by sudo su - user. that is i can login to xyz using my id and then switch to user and run the script.
Now what i need to do is run the script from another script in machine xyz1. From xyz1 i can ssh to xyz using my id. Some one please help me in doing this.
You can do this without having to do the sudo bit, it can be a bit tricky and the man page is a pain to read...
Instead, create some ssh-keys for your user on xyz1. copy the public key to the target user's .ssh directory in in home dir, into the file authorized_keys.
Now ssh as the user on xyz1 using the shiny new private key to xyz and run the script:
Another thing- it will make it easier if you could be a little less cryptic in your question- instead of hosts xyz and xyz1, users user and id you could just give them some names:
I have a script evilscript.sh accessable by eviluser on machine avalon. I have another user called bob on avalon as well. The user bob exists on machine houston.
I want my user bob on houston to log onto avalon then, using sudo, run script evilscript.sh as user eviluser.