Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Howto shutdown a GentooServer from Windows
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Krenn
n00b
n00b


Joined: 11 Jan 2003
Posts: 24
Location: Austria

PostPosted: Thu Nov 13, 2003 11:12 am    Post subject: Howto shutdown a GentooServer from Windows Reply with quote

Ok i have successfully made a little home-server with sshd, samba for backup files and so on.
My problem is that some people of my family only use Windows (2k, xp)

Whenever the server is needed (so not everyday) they can come in my room and turn the monitorless Celeron333, 64mb-ram on.

But i have always to turn it off by ssh root@192...

What is an easy solution for them to shut it down without a password (at least not root) ans by a simple procedure.

Here some of my thoughts:

Booting Linux and use ssh: they don't have Linux
Using Winscp and its console: too complicated, root is needed
apache with php or java (started learning): userfriendly but possible?

Im open to any ideas.
_________________
MfG
Vrenn/Krenn
Back to top
View user's profile Send private message
fzimper
n00b
n00b


Joined: 17 Jan 2003
Posts: 61
Location: Germany

PostPosted: Thu Nov 13, 2003 11:29 am    Post subject: Reply with quote

You can use ssh on Windows.

Then you create a user which has the right to shutdown the Gentoo Server and create a subdirectory .ssh in this user's home dir. On the Win machine you run ssh-keygen and copy the file identity.pub to the Linux machine in ~/.ssh and name it authorized_keys.

This way, you can run 'ssh -l user gentoo.domain.de' without being asked for a password.

This has helped me a lot in setting up a similar scenario.
Back to top
View user's profile Send private message
fleed
l33t
l33t


Joined: 28 Aug 2002
Posts: 756
Location: London

PostPosted: Thu Nov 13, 2003 11:29 am    Post subject: Reply with quote

I would suggest you create a separate user in your gentoo box just for shutdown. Then create ssh keys so you can login without using passwords.
Then install putty on the windows machines with the shared key installed.

Change the shell for the user you created to a script which calls shutdown -h now.
Create an icon in the windows desktops that calls putty with the right flags to login as the gentoo user. This way whenever your folks double click on the icon the machine will be shutdown.

Or even better: teach them linux!
Back to top
View user's profile Send private message
fleed
l33t
l33t


Joined: 28 Aug 2002
Posts: 756
Location: London

PostPosted: Thu Nov 13, 2003 11:30 am    Post subject: Reply with quote

Beat me to it by a few seconds, I reckon!
Back to top
View user's profile Send private message
Krenn
n00b
n00b


Joined: 11 Jan 2003
Posts: 24
Location: Austria

PostPosted: Wed Dec 03, 2003 1:17 pm    Post subject: Reply with quote

Thanks for your ideas, but somebody told me it is possible to shut down the server with php (this would really be OS-independent)

I did following:

emerges mod_php sudo, set safe mode = off, made a page with system ("sudo shutdown -h now"); and enabled the commando for group apache by sudos config-programm.

php (by phpinfo()) seems to work but server is still not shutting down... im working on that.

Anyway your ideas where great too,
especially
Quote:
Or even better: teach them linux!

Im working on that too (hard work believe me)
_________________
MfG
Vrenn/Krenn
Back to top
View user's profile Send private message
jesterspet
Apprentice
Apprentice


Joined: 05 Feb 2003
Posts: 215
Location: Atlanta

PostPosted: Fri Dec 05, 2003 3:27 am    Post subject: Reply with quote

staying in the ssh route, rather than create a new or separate user. You can create a separate key for running a forced command

*** Plagiarized from the book ***
A forced command transfers this control from the client to the server. Instead of the client's deciding which command will run, the owner of the server account decides.

In SSH2, a forced command appears on the line immediately following the desired Key, using the Command keyword.

e.g.
Code:

# SSH2 key to shutdown my server
Key secondary_unique_purpose_key.pub
Command "/sbin/shutdown"


You may associate at most one forced command with a given key.

*** End plagiaristic posting ***

With this method, you can distribute the key to computers you trust, to shut down the server. If you provide a passphrase for the key, that passphrase will be checked on the client end, and can be changed at will without changing anything on the server end.

This is provided you use public key authentication on the server end.

You can learn all about neat stuff you can do with ssh (including even more about forced commands) in SSH, The Secure Shell: The Definitive Guide .
_________________
(X) Yes! I am a brain damaged lemur on crack, and would like to buy your software package for $499.95
Back to top
View user's profile Send private message
cdunham
Apprentice
Apprentice


Joined: 06 Jun 2003
Posts: 211
Location: Rhode Island

PostPosted: Fri Dec 05, 2003 3:49 am    Post subject: Reply with quote

Why not just keep it running all the time? If noise is an issue, maybe there is someplace out of the way it could go?

Then you can run cron jobs on it, like mrtg and all-important things like that! :-)
_________________
This post more meaningful in a scalar context.
Back to top
View user's profile Send private message
Lews_Therin
l33t
l33t


Joined: 03 Oct 2003
Posts: 657
Location: Banned

PostPosted: Fri Dec 05, 2003 6:13 am    Post subject: Reply with quote

Put putty on the window machines
Edit /etc/ssh/sshd_config so blank passwords are allowed
Make a user with a blank password that can shut down
put "/sbin/shutdown now && logout" into the user's .bashrc

Whenever they want to shut down the comp, they just login on that user.
Back to top
View user's profile Send private message
rockfly
Apprentice
Apprentice


Joined: 27 Apr 2003
Posts: 179

PostPosted: Fri Dec 05, 2003 10:22 am    Post subject: Reply with quote

if you are not in X-window , but in the console, just press ctrl+alt+del to reboot the computer.
Back to top
View user's profile Send private message
jesterspet
Apprentice
Apprentice


Joined: 05 Feb 2003
Posts: 215
Location: Atlanta

PostPosted: Fri Dec 05, 2003 1:50 pm    Post subject: Reply with quote

Lews_Therin wrote:
Edit /etc/ssh/sshd_config so blank passwords are allowed


This solution still prompts for passwords. Users will just have to hit enter when prompted.

It also opens up security holes. Unless you have set all user acounts assigned to services (like lp,cron,uucp, etc) to have a shell of /bin/false or similar, others can login to your Linux box as those services, with no password, and do whatever they feel like.


rockfly wrote:
if you are not in X-window , but in the console, just press ctrl+alt+del to reboot the computer.


This solution requires the users to be logged in localy to the computer. Since the users are on windows machines, the Ctrl+Alt+Del shortcut will restart the windows computers instead of the Linux Server.
_________________
(X) Yes! I am a brain damaged lemur on crack, and would like to buy your software package for $499.95
Back to top
View user's profile Send private message
Danrol
n00b
n00b


Joined: 23 Feb 2003
Posts: 23

PostPosted: Sat Dec 06, 2003 7:30 pm    Post subject: Reply with quote

I used to use an IPCop server in a similar way, but used a different approach to the shutdown.

I made a simple script that pings the PC addresses, if there is no reply the server will shutdown. I ran the script as a cron job every 5 or 10 mins. If your interested I might still have the script lying around.
Back to top
View user's profile Send private message
Danrol
n00b
n00b


Joined: 23 Feb 2003
Posts: 23

PostPosted: Sat Dec 06, 2003 7:31 pm    Post subject: Reply with quote

I used to use an IPCop server in a similar way, but used a different approach to the shutdown.

I made a simple script that pings the PC addresses, if there is no reply the server will shutdown. I ran the script as a cron job every 5 or 10 mins. If your interested I might still have the script lying around.
Back to top
View user's profile Send private message
`xin`
n00b
n00b


Joined: 16 Jul 2003
Posts: 19
Location: Ferrara

PostPosted: Sat Dec 06, 2003 7:42 pm    Post subject: Reply with quote

Krenn wrote:
Thanks for your ideas, but somebody told me it is possible to shut down the server with php (this would really be OS-independent)

I did following:

emerges mod_php sudo, set safe mode = off, made a page with system ("sudo shutdown -h now"); and enabled the commando for group apache by sudos config-programm.

php (by phpinfo()) seems to work but server is still not shutting down... im working on that.

Anyway your ideas where great too,
especially
Quote:
Or even better: teach them linux!

Im working on that too (hard work believe me)


Hi,
I have done a small webpanel to control my gateway/firewall using sudo apache and php. Remember to give to the user "nodody" a shell editing /etc/passwd:
Code:
nobody:x:99:99:nobody:/:/bin/bash


I use
Code:
system("/usr/local/bin/sudo -u root /usr/shutdown -h now");

to shutdown the system, exec() will also work.

Bye.

Michele `xin` Barboni[/code]
Back to top
View user's profile Send private message
Krenn
n00b
n00b


Joined: 11 Jan 2003
Posts: 24
Location: Austria

PostPosted: Sun Dec 14, 2003 1:15 pm    Post subject: Reply with quote

I have trided something simmilar (php: "system("sudo shutdown -h now");" but it didnt work.
I allowed group apache (and users for testing) by sudo-conf-tool to shut down: didn't work.
I logged in as a user and tryed to shut down by "sudo shut..." what gave me a passwordprompt. Reading the man, password has to be the same like the user usually has: didn't work.
Either way, what password does have the user/group apache?
Why is sudo questioning the user-password when I allowed a group to shut down?
I thought sudo exists because people want to do things without logging in again and how can the user apache give sudo his password on the way.
(at least, what is it?)

Quote:
I have done a small webpanel to control my gateway/firewall using sudo apache and php. Remember to give to the user "nodody" a shell editing /etc/passwd/
Code:
nobody:x:99:99:nobody:/:/bin/bash

nice idea but what does it? :?:

My visudo:
Code:
root    ALL=(ALL) ALL
 %users  localhost=/sbin/shutdown -h now
 %apache  localhost=/sbin/shutdown -h now

_________________
MfG
Vrenn/Krenn
Back to top
View user's profile Send private message
Krenn
n00b
n00b


Joined: 11 Jan 2003
Posts: 24
Location: Austria

PostPosted: Sun Dec 14, 2003 3:05 pm    Post subject: FAQ for this diskussion Reply with quote

FAQ for this diskussion:
Q: Why don't you use ssh, putty or cygwin?
A: Because I want to shut it down from all my systems including Windows 98/2000/3.11/BEOS/Linux

Q: Why don't you let it running?
A: I sleep in the same room.

Q: Isn't there a place in the cellar?
A: Yes it is, considering the fact that im living at the floor Numer 7 and that it has no electricity.

Q: Isn't that a strange server?
A: Actually no, its just for Programms (Openoffice, tools...), backups and rescue (when a friend is coming again having "Blaster Inside(R)")

Q: What was first, the chicken or the egg?
A: The chicken.
_________________
MfG
Vrenn/Krenn
Back to top
View user's profile Send private message
Linki
n00b
n00b


Joined: 12 Nov 2003
Posts: 23
Location: Switzerland

PostPosted: Thu Dec 18, 2003 8:27 am    Post subject: Reply with quote

Danrol wrote:
I used to use an IPCop server in a similar way, but used a different approach to the shutdown.

I made a simple script that pings the PC addresses, if there is no reply the server will shutdown. I ran the script as a cron job every 5 or 10 mins. If your interested I might still have the script lying around.


I think this would be a quiet nice idea. The server just checks serveral IP adresses and if they're not responding the server will shutdown.

Do you still have the script?
Or does somebody know a similar-working script or is there even a deamon for that?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum