Linux - GeneralThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
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
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) ?
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.
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, ...
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.