Change user on remote machine and execute script!

Hi,

I need to login into remote server and execute a shell script over there.

As of now i am making use of ssh command

ssh primUser@135.254.242.2 sh /poll.sh

I am logging in as primUser but unless i change the user to root the script execution on the remote machine is not possible.

Is there a way wherein i can make use of perl script or anything like that and remotely change the user to root?

ssh primUser@135.254.242.2 su -

The above command is giving me a 'su - Sorry' message.

Can anybody help me to change the login to root on remote machine and execute the script poll.sh on it?

Configure the ssh to add the keys for the "root" on the remote server!!! . But remember it is highly risky!!!

So configure (or install...) sudo on your remote host so that the script is executed by primUser as root...

Can any one tell me how to add keys for user root of remote server onto my present machine?

I am trying the ssh-keygen command but its giving a ssh-keygen command not found error. Any links to webpage of how to configure is highly appreciated!

Can any one tell me how to add keys for user root of remote server onto my present machine?

I am trying the ssh-keygen command but its giving a ssh-keygen command not found error. Any links to webpage of how to configure is highly appreciated!

============================================
check this link

System Administration Toolkit: Distributed administration using SSH

In windows machine if you have cygwin installed

goto to cygwin
mkdir -p .ssh
ssh-keygen -t dsa -f .ssh/id_dsa -P ''

then append the contents of .ssh/id_dsa.pub to /export/home/buildusr/.ssh/authorized_keys(10.18.51.62)

cat id_dsa.pub >> /export/home/buildusr/.ssh/authorized_keys

Hi,

you can run "ssh primUser@135.254.242.2 "su - user -c command_to_run"

hope this will help