LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-06-2010, 04:42 AM   #1
deelinux
Member
 
Registered: Nov 2009
Posts: 35

Rep: Reputation: 15
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
 
Old 08-06-2010, 04:46 AM   #2
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by deelinux View Post
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
 
Old 08-06-2010, 06:19 AM   #3
deelinux
Member
 
Registered: Nov 2009
Posts: 35

Original Poster
Rep: Reputation: 15
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
 
Old 08-06-2010, 06:37 AM   #4
sem007
Member
 
Registered: Nov 2006
Distribution: RHEL, CentOS, Debian Lenny, Ubuntu
Posts: 638

Rep: Reputation: 111Reputation: 111
Quote:
Originally Posted by deelinux View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Delay before password prompt over ssh. cov Linux - Networking 14 07-16-2009 02:53 PM
ssh no password prompt dtra Linux - Software 9 05-25-2005 02:08 PM
ssh password prompt delay long while chaze Linux - Networking 1 04-14-2005 11:03 PM
ssh without the password prompt markehb Linux - Networking 27 03-25-2004 12:12 PM
remote command over ssh, password prompt linowes Linux - General 2 10-27-2002 09:22 PM


All times are GMT -5. The time now is 12:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration