Change user on remote machine and execute script!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Change user on remote machine and execute script!
# 1  
Old 09-01-2008
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?
# 2  
Old 09-01-2008
Quote:
Originally Posted by goutham4u
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!!!
# 3  
Old 09-01-2008
So configure (or install...) sudo on your remote host so that the script is executed by primUser as root...
# 4  
Old 09-02-2008
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!
# 5  
Old 09-20-2008
key generation

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
# 6  
Old 10-24-2008
Hi,

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

hope this will help
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Execute ssh command with additional terminal command to any remote user not working script

Hello i am having an issue with bash script and this is the code now=$(cat hosts1.txt | awk '{print $2;}') while read n ;do ssh root@$now 'useradd test1; echo -e "test1\ntest1" | passwd test1 && echo "test1 ALL=(ALL:ALL) ALL" >> /etc/sudoers' When i execute only part with cat, it... (8 Replies)
Discussion started by: tomislav91
8 Replies

2. Shell Programming and Scripting

How can I execute local script on remote machine and include arguments?

I have a script in local server cd /home/dell/work/BOP/testdir ./processchk po (here processchk is a script & po is passed as an argument) Now I want to execute this script from remote server ssh $username@$hostname "cd /home/dell/work/BOP/testdir; ./processchk po" But Its getting error... (9 Replies)
Discussion started by: manohar2013
9 Replies

3. Shell Programming and Scripting

Execute shell script on remote machine

I want to execute a shell script(set of commands) on remote machine and that script takes input from text file(local machine). Please refer below: ssh user@hostname 'bash -s'< ./test.sh file.txt But i got the error file.txt doesn't exist. Can anyone help me on this. Content of test.sh: ... (2 Replies)
Discussion started by: manishtri88
2 Replies

4. UNIX for Dummies Questions & Answers

Execute shell script in remote machine

Hi All, We have 2 servers A and B. B is having a sctipt called b.sh in path /home/dev/scripts. Now my requirement is i want to execute b.sh from server A. Kindly help me. (3 Replies)
Discussion started by: Girish19
3 Replies

5. IP Networking

Execute script located on a remote machine

So, is there way of automating this ? My ultimate goal is to run some cmd script in windows and it should connect to a remote unix host and run a script x.sh located on the remote unix host. I was wanting to achieve this by using WinSCP and Putty only. If possible let me know how and if not... (25 Replies)
Discussion started by: mohtashims
25 Replies

6. Shell Programming and Scripting

How to execute a script hosted on a machine from a different machine

Hi everyone I intend to trigger a script from one machine say mc1 that actually excutes on different machine say mc2 and redirect the logs to that machine mc2. I tried to use nohup <nfs location of machine >/script.sh > <nfs location of machine >/script.log 2>&1 & nfs location of... (2 Replies)
Discussion started by: harneetmakol
2 Replies

7. Shell Programming and Scripting

Execute command from terminal on remote machine

Hi All, I want to execute some commands on unix machine from the mac machne. I have two options for doing so, I am confused which is the best way of doing. Here are two options. Requirement: Execute command on the remote server machine. Commands to be executed itself contain arguments to be... (0 Replies)
Discussion started by: Ranu
0 Replies

8. Shell Programming and Scripting

change files permission on Remote machine

I would like to change permissions recursively on a remote folder. Seems like sftp has a limitation, I am only able to change permission on a individual file.. sftp > chmod 777 /usr/local/apache/docs/test.txt It would be great if someone has more knowledge on how this is doable recursively? (1 Reply)
Discussion started by: almeisan1
1 Replies

9. Shell Programming and Scripting

how to execute a script on remote machine

hi unix guru's i am new to unix shell programming. i found a trouble in executing a script(bali.ksh) which is available on serverA with username xyza, this script contains sqlplus command to retrive the data from the database available on other serverC. Now i need to run the above script... (4 Replies)
Discussion started by: balireddy_77
4 Replies

10. SCO

Need Script to check whether user exists in the remote machine

Hi All, I am new to shell scripting. Can someone let me know, how to check whether the user exists in the remote system? I am building a new unix box and before I proceed installing the appliation , I want to check whether the required users are created in the system . how to do this ?... (1 Reply)
Discussion started by: Srini75
1 Replies
Login or Register to Ask a Question