LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ssh - scripts - password prompt (https://www.linuxquestions.org/questions/linux-newbie-8/ssh-scripts-password-prompt-824529/)

deelinux 08-06-2010 03:42 AM

ssh - scripts - password prompt
 
Hello

I have successfully configured ssh, I can login to my remote Linux server without being prompted for a password, however when I try an add this into a script I get prompted for a password...

What Im trying to do is is to login remotely using ssh then run a command using the root user:

From my Linux server I run
sudo -u my_ssh_account ssh my_ssh_account@my-remote-server.com sudo - root /tmp/mycommand

This works, but when I put it into a script it prompts me to enter the ssh accounts password...and Im puzzled

Any thoughts suggestions would be apreciated .

D

sem007 08-06-2010 03:46 AM

Quote:

Originally Posted by deelinux (Post 4057645)
Hello

I have successfully configured ssh, I can login to my remote Linux server without being prompted for a password, however when I try an add this into a script I get prompted for a password...

What Im trying to do is is to login remotely using ssh then run a command using the root user:

From my Linux server I run
sudo -u my_ssh_account ssh my_ssh_account@my-remote-server.com sudo - root /tmp/mycommand

This works, but when I put it into a script it prompts me to enter the ssh accounts password...and Im puzzled

Any thoughts suggestions would be apreciated .

D

It might asking sudo password.

Can you paste your script

deelinux 08-06-2010 05:19 AM

Hello its very basic script

#!/bin/bash
echo "My test command is running"
sudo -u test1 ssh test1@myserver.com sudo -u root -s /tmp/mytestscript.sh
exit


Im just wondering do you have to put sudo su and not sudo -u

sem007 08-06-2010 05:37 AM

Quote:

Originally Posted by deelinux (Post 4057716)
Hello its very basic script

#!/bin/bash
echo "My test command is running"
sudo -u test1 ssh test1@myserver.com sudo -u root -s /tmp/mytestscript.sh
exit


Im just wondering do you have to put sudo su and not sudo -u

just try below

ssh test1@myserver.com /tmp/myestscript.sh


All times are GMT -5. The time now is 12:08 AM.