Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > macOS > Shell script, SSH and SUDO problem

Shell script, SSH and SUDO problem
Thread Tools
BostonMACOSX
Forum Regular
Join Date: Nov 2000
Location: Boston Area,ma
Status: Offline
Reply With Quote
Jan 14, 2003, 04:27 PM
 
Hello to all:

This is the problem that I am facing. I am able to log into machien via SSH unattended but I want to run a script using SUDO. However SUDO prompts for a password.

Any ideas how to get around this. Is there someway of having the script enter the password for me or ro disable the need to be prompted.

thanks in advance.

Basically I want to write a script that logs into 25 machines and reboots them one at a time.

thanks
BostonMACOSX
OSX ...Plastic surgery for unix
Boston Area Consulting
http://rjhcc.dyndns.biz
http://bostonmacosx.dyndns.org
     
clarkgoble
Mac Elite
Join Date: Mar 2001
Location: Provo, UT
Status: Offline
Reply With Quote
Jan 14, 2003, 04:52 PM
 
Modify /etc/sudoers so that it doesn't ask for a password. It's less secure, obviously, but it typically the only way to deal with scripting and not putting a password in an insecure area.

man sudo for more info on how the sudoers file works. (Actually it should have the modifications in it, commented out)
     
BostonMACOSX  (op)
Forum Regular
Join Date: Nov 2000
Location: Boston Area,ma
Status: Offline
Reply With Quote
Jan 14, 2003, 04:56 PM
 
Originally posted by clarkgoble:
Modify /etc/sudoers so that it doesn't ask for a password. It's less secure, obviously, but it typically the only way to deal with scripting and not putting a password in an insecure area.

man sudo for more info on how the sudoers file works. (Actually it should have the modifications in it, commented out)
Sorry for the ignorance....but what change should I make to it?
Can I limit the Sudo to a single user and not a group like admin.

thanks
OSX ...Plastic surgery for unix
Boston Area Consulting
http://rjhcc.dyndns.biz
http://bostonmacosx.dyndns.org
     
rantweasel
Dedicated MacNNer
Join Date: Oct 2001
Location: Philly
Status: Offline
Reply With Quote
Jan 14, 2003, 06:18 PM
 
Originally posted by BostonMACOSX:
Sorry for the ignorance....but what change should I make to it?
Can I limit the Sudo to a single user and not a group like admin.
You can even limit it to a single user and command, so that user bob can log in and run shutdown as root, but nothing else. Read the manual page for the exact sytax - it should be something along the lines of

'user hostname = NOPASSWD: /sbin/shutdown'

but I don't have OSX in front of me, so I'm not 100% on that...

mathias
     
Camelot
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status: Offline
Reply With Quote
Jan 14, 2003, 09:00 PM
 
Originally posted by clarkgoble:
Modify /etc/sudoers so that it doesn't ask for a password. It's less secure, obviously, but it typically the only way to deal with scripting and not putting a password in an insecure area.

man sudo for more info on how the sudoers file works. (Actually it should have the modifications in it, commented out)
The problem isn't with sudo asking for the password, it's the remote machines asking for a password as you log in.

Even if you launch your script under sudo on your current machine, when you ssh to the first machine you'll be asked for a password again.

The easiest way to do this is to setup public key logins on each machine so that the central machine can log in using public key authentication rather than username/password.

man ssh-keygen for details on how to do this.
Gods don't kill people - people with Gods kill people.
     
   
 
Forum Links
Forum 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 On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 11:59 PM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,