LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 10-15-2014, 06:36 AM   #16
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled

Running "shutdown -h now" remotely returns error.
Quote:
bash: shutdown: command not found
Running "sudo shutdown -h now" remotely returns error:
Code:
sudo: sorry, you must have a tty to run sudo
"/sbin/shutdown -h now" and "/usr/sbin/shutdown -h now" both return same error:
Code:
Failed to issue method call: Access denied
Must be root

Last edited by Nick_C; 10-15-2014 at 06:44 AM.
 
Old 10-15-2014, 09:28 AM   #17
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i'm curious:
Code:
sudo /sbin/shutdown -h now
# or sudo /usr/sbin/shutdown -h now
?

also, what happens when you log in via ssh then run the commands using sudo (also try with specifying the path).

Last edited by schneidz; 10-15-2014 at 09:30 AM.
 
Old 10-15-2014, 11:49 AM   #18
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
i'm curious:
Code:
sudo /sbin/shutdown -h now
# or sudo /usr/sbin/shutdown -h now
?

also, what happens when you log in via ssh then run the commands using sudo (also try with specifying the path).
  • Logon to SSH as remoteshutdown
  • shutdown /h now
Code:
Authentication is required for powering off the system.
Authenticationg as: <DifferentUser>
Edit:
Have now found a way to make 'remoteshutdown' an Administrator which it was not before. This has changed things slightly, running from SSH /usr/sbin/shutdown -h now
Code:
Authentication is required for powering off the system.
Multiple identities can be used for authentication:
1 . <DifferentUser>
2 . remoteshutdown
Choose identity to authenticate as

Last edited by Nick_C; 10-15-2014 at 12:03 PM.
 
Old 10-15-2014, 12:55 PM   #19
ReaperX7
LQ Guru
 
Registered: Jul 2011
Location: California
Distribution: Slackware64-15.0 Multilib
Posts: 6,558
Blog Entries: 15

Rep: Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097Reputation: 2097
Does your distribution use ConsoleKit or logind for session management?
 
Old 10-15-2014, 02:20 PM   #20
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by ReaperX7 View Post
Does your distribution use ConsoleKit or logind for session management?
No idea, using CentOS 7.0
 
Old 10-15-2014, 02:27 PM   #21
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
Originally Posted by schneidz View Post
also, what happens when you log in via ssh then run the commands using sudo (also try with specifying the path).
i.e.-
Code:
ssh remoteshutdown@host
sudo /usr/sbin/shutdown -h now

Last edited by schneidz; 10-15-2014 at 02:33 PM.
 
Old 10-15-2014, 03:20 PM   #22
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
i.e.-
Code:
ssh remoteshutdown@host
sudo /usr/sbin/shutdown -h now
ssh remoteshutdown@n.n.n.n
Code:
The authenticity of host 'n.n.n.n' can't be established.  ECDSA key fingerprint is ...... Are you sure you want to continue connecting (yes/no)?  Answer 'yes'
now logs-in ok

sudo /usr/sbin/shutdown -h now
Shuts-down server ok

Run batch file
plink.exe -ssh -pw <password> remoteshutdown@n.n.n.n "/sbin/shutdown -h now"
Error:
Code:
Failed to issue method call: Access denied
Must be root.

Last edited by Nick_C; 10-15-2014 at 03:30 PM.
 
Old 10-15-2014, 03:27 PM   #23
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
Quote:
Originally Posted by Nick_C View Post
ssh remoteshutdown@n.n.n.n
The authenticity of host 'n.n.n.n' can't be established. ECDSA key fingerprint is ...... Are you sure you want to continue connecting (yes/no)? Answer 'yes'
now logs-in ok

sudo /usr/sbin/shutdown -h now
Shuts-down server ok
good so you added permission for remoteshutdown to run that command via visudo (did it prompt for a password ?).

so now are you trying to make it so that remoteshutdown can shutdown the server via something like:
Code:
ssh remoteshutdown@n.n.n.n sudo /usr/sbin/shutdown -h now
i think sudo requires someone to be logged in for security reasons (there may be a way to disable that) ?
 
Old 10-15-2014, 03:33 PM   #24
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
i think sudo requires someone to be logged in for security reasons (there may be a way to disable that) ?
Which is why I was not sure that sudo is the correct way of doing this, I had hoped that there would have been a simpler way of doing this like changing the group on the shutdown command or something like that.
 
Old 10-15-2014, 03:58 PM   #25
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
that mite work. what does
Code:
which shutdown
ll /sbin/shutdown /usr/sbin/shutdown
look like ?
 
Old 10-16-2014, 09:37 AM   #26
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by schneidz View Post
that mite work. what does
Code:
which shutdown
ll /sbin/shutdown /usr/sbin/shutdown
look like ?
which shutdown
Code:
/usr/sbin/shutdown
ll /sbin/shutdown /usr/sbin/shutdown
Code:
lrwxrwxrwx. 1 root root 16 Sep 25 16:11 /sbin/shutdown -> ../bin/systemctl
lrwxrwxrwx. 1 root root 16 Sep 25 16:11 /usr/sbin/shutdown -> ../bin/systemctl
Does that help
 
Old 10-16-2014, 09:40 AM   #27
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
i would be concerned with changing permissions on the systemctl program becuz then remoteshutdown would be allowed to do other things like restart sshd, httpd, mysqld, ...
 
Old 10-16-2014, 09:50 AM   #28
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
this mite help:
http://maymay.net/blog/2010/03/17/ho...cing-security/
 
Old 10-16-2014, 10:20 AM   #29
Nick_C
Member
 
Registered: Jan 2012
Location: London, England, UK
Distribution: CentOS 6, CentOS 7
Posts: 299

Original Poster
Rep: Reputation: Disabled
Code:
chmod +s /sbin/shutdown
then plink line works fine without any of this sudoers complication
Code:
plink.exe -ssh -pw <password> remoteshutdown@n.n.n.n "/sbin/shutdown -h now"
Simples

Thanks for all your help with this

Last edited by Nick_C; 10-16-2014 at 10:35 AM.
 
Old 10-16-2014, 10:27 AM   #30
schneidz
LQ Guru
 
Registered: May 2005
Location: boston, usa
Distribution: fedora-35
Posts: 5,313

Rep: Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918Reputation: 918
thanks for sharing your solution. my suggestion would be to use keys instead of writing down the passwd.

if it is solved please select resolved under thread tools.
 
  


Reply

Tags
centos, shutdown



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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] mount, shutdown as non-root user darksaurian Slackware 7 06-06-2010 11:25 PM
shutdown with a not root user krusty_lab AIX 2 10-18-2005 06:07 PM
Root User freezes on logout or shutdown grizzlyaka Linux - Laptop and Netbook 2 04-27-2005 08:20 AM
Can't shutdown as any user but root? JustinCoyan Slackware 4 06-10-2004 01:05 PM
how to allow a not root user to shutdown ethanchic Linux - General 9 06-18-2002 05:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:01 AM.

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
Open Source Consulting | Domain Registration