Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I have a personal Debian server set up, that I'm able to access in person and remotely, but normally I'm away from it and it's remote. It's on a battery-backup surge protector, but sometimes that isn't enough to keep the server on through a power outage. The machine automatically starts and boots, but its left at the login screen (in person). What I want to know is, what is the best way to have the server get itself back on and online after it loses power, without leaving it vulnerable in person? I'd like it to not auto-login for the screen in person, so that the machine isn't overly vulnerable in-person while I'm away.

Are there battery backups that signal for hibernation or other safe power down automatically? How can I have a user sign in automatically in the background? What would you recommend as a "best practice" for this, considering it's just a home server?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

Make sure your BIOS is set to restart the system after a power failure.

Turn off auto login unless you have a really good reason for it to be enabled. You shouldn't really need to be interactively logged on for any server type programs to function. Especially if you can get into the system remotely there is no reason for it.

For most any program you need running in the background you can either make an initscript (if there isn't one already) or start it from rc.local without needing to be logged in.

For example, I have apache running on my home server. It launches and runs in the background when I boot. I don't have to explicity start it when my server comes up.

Most battery backups over $50 have a serial port or other mechanism for communicating with a PC. If yours is an APC (a really common brand), you want a package called apcupsd. This lets you call scripts when the power goes out, comes back on, and the system is about to shut down because of low battery. Most battery backups support Linux, it's just a matter of going on the manufacturer's website or doing a bit of Googling.

Generally power events are delivered to init and then init calls the respective programs. Look at /etc/inittab and the comments illustrate this.

You can actually disable console login entirely if you really want to by removing all the "getty" lines in inittab. Don't recommend you do that though, because if your network fails or you misconfigure sshd one day you are screwed.

share|improve this answer
1  
I've used a package called apcupsd for shutting down a machine when it switched to battery on power failure. I've not heard of apcaccess. –  Faheem Mitha May 24 '11 at 19:47
    
Oh yeah, that's the name of the package. apcaccess is the name of the command line utility that is part of it which outputs its current status. My mistake. I'll edit to correct. –  ultrasawblade May 24 '11 at 20:03
    
Just one question: without the auto-login, do I have to remotely access the machine to restart the server? I'm not totally clear on it. –  DavidJFelix May 25 '11 at 2:42
1  
With no auto-login the system will boot to a login prompt. You then login and do whatever you want. –  ultrasawblade May 25 '11 at 2:45
    
Is there a way that I could have the user auto-logged in, in the background (as if I had ssh'ed in and logged in), so that all of the processes that I would do when I logged in will be automatic? –  DavidJFelix May 26 '11 at 13:39
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.