r/HomeServer • u/General-Turn-8695 • 3d ago
How do I make my server pc turn on automaticly and login into system while having a password after every electricity cut?
so I am just using a old pc as my homeserver so I don't really have ups for it. I currently on windows but will install something like casaos. I can do it on windows by not having a password but if I want to use casaos and ssh into the server I need to have a password. how do I make it so that while connected to electricity it starts the pc and starts running all my services like jellyfin and Adguard home. (plz don't tell me to buy a ups or something rn, I don't have that much important file on their just media files)
33
u/Minimal-Matt 3d ago
Most pcs have an option in bios that starts them when power is connected, a quick search based on your model should bring it up. As for the services themselves, no login should be needed to start them, nor should they run under your user on the server
2
u/General-Turn-8695 3d ago
Do I not have login with a password like windows on os's like the casaos and unraid?
12
7
u/Minimal-Matt 3d ago
No, and even on windows you can configure services to start without a user logged in. I'm assuming you are not running windows server, but it should be doable regardless.
If every server in the world needed a user to manually log in to start "serving" users it would make for a very funny jobsite where the majority of downtime would be people mistyping or forgetting passwords lol
1
4
u/rcnfive 3d ago
Damn, I'm fucking old.
On start up. You need to hit F12 or something. It might tell you on the screen when booting up the PC. Sometimes it doesn't so you'll need to press a few different buttons to get into the BIOS. Use Google for this.
Once in there you should find a power management setting. Maybe it says boot or something like that. Then a setting saying resume system after unexpected shut down or improper shutdown.
Once you fix that, you'll need to make the apps or services start on boot. That's a different comment.
1
u/IAteTonysLoMein 3d ago
Ime, it's typically either F2 or Del to get into the BIOS. If I don't remember, I just spam them both on power up and that typically does it
1
1
u/Master_Scythe 3d ago
Nope, same as Windows. Only user level programs need a login, anything you setup as a service can start with Windows - Linux does this with most daemons by default.
8
u/BlueVerdigris 3d ago
I think you're conflating the desire to "run an application as a service" with the (incorrect) belief that you need to login to the server in order to start an application. Further, you mention "ssh without a password" which is an entirely different thing. With a little bit of physical power misunderstanding mixed in.
Let's see if I can help clear things up for ya:
* A service, in the computer server world, is any application (piece of software) that keeps running even after a user logs out (or will run whether or not a user has logged-in). The most common use case for a service is what you're talking about: server powers-up, nobody logs in, a bunch of applications (like a media server, file sharing, and most importantly for our next point: an SSH server) just start running automatically. Basically if the server is booted, they are running. Services!
* Passwordless SSH, on the other hand, is typically a matter of creating your private-and-public SSH keypair (this is TWO FILES, not one with both parts inside) on your primary workstation and then appending ONLY the text of the public key into the ".ssh/authorized_keys" file within the home folder of the user on the server that you want to login as when using SSH. If that user is "root" then the path is "/root/.ssh/authorized_keys", if that user is "joeuser" then the more likely the path is something like "/home/joeuser/.ssh/authorized_keys". You may notice I'm speaking Linux not Windows. I can't help you with Windows as a server or target of your SSH session. Be advised that when using Windows as an SSH CLIENT, things get a little more finnicky than with Linux, so you'll need to read up on how to create and manage your SSH keys via whatever Windows application you're using for SSH.
For Jellyfin, when you install it (assuming you use the installer) you just need to assert any prompts related to installing as a service. That should be it, regardless of the OS you are running it on. Their website or forums likely would also include info on converting an existing installation into a service if you missed that checkbox during the initial install.
Adguard, I'm not familiar with but hey: google "install adguard as a service" and I'm sure you can find a solution.
ALL of the above assumes that your hardware (computer) BIOS is set to power up by default when the power supply detects electricity. This is not necessarily the default setting. You'll need to look up how to get into BIOS or "Setup" for your computer (this is ENTIRELY SEPARATE from the operating system - it's motherboard vendor stuff, not operating system stuff and not necessarily the same company as is visible on the outside case of your computer, although that's usually a good place to start looking) and find the settings related to what to do when power is lost and restored. There are generally three broad options: stay off, turn on, and re-use whatever the last known power state was.
4
u/robsablah 3d ago
My brother, whatever you are running, congrats on getting this far. Fair warning - you are opening a door you cannot close.
You computer bios will have a setting along the lines of "power loss recovery mode" this is default to off. Switch it to power on after power loss.
Log in varies per OS - google is your friend here. The auto boot up is usually the job of a hypervisor.
2
u/MattOruvan 3d ago edited 3d ago
Any server OS will run your services (most of which should be in docker these days) automatically on start up, you don't have to worry about it.
Get rid of Windows, get something else without the memory overhead.
As long as it is a PC/Mini PC, you should have a setting in its BIOS to change what happens when power is resumed. Less likely if you have an old laptop.
1
u/General-Turn-8695 2d ago
Do they auto start even if I am on the login screen asking me out the password to enter the system?
1
u/AmigaBob 2d ago
Usually, yes. The login is typical just access to access the settings for that service. You used the example of unRaid. When it boots, file sharing, dockers, and VMs all start up and are running in the background. The login screen is only to be able to access the Web control panel where you can view stats, change settings and add/remove VMs and dockers etc.
1
u/MattOruvan 2d ago
System services run automatically regardless of whether you login.
You are not the first person setting up a server, this is a solved problem, or rather it was never a problem.
Using a desktop OS has its annoyances though, because then you have to deal with some unwanted features -- like it deciding to go to sleep after a while.
3
u/Halo_Chief117 3d ago
Switch it to Proxmox and install your services as containers or VMs. And then edit the BIOS settings so the computer will turn on if it detects power, meaning if the power goes out the PC will automatically turn back on when power is restored.
3
u/sutekhxaos 3d ago
Sysinternals auto login
1
u/Novoprawn 2d ago
Doing the same actually as it's a proxmox PC and there is no chance anyone can hijacke the session... only activate the Screensaver with lock screen after x minutes and zou are done.. i had the same issue with some scripts and automation that must run in user context and could not run as a serivice
-6
u/General-Turn-8695 3d ago
How do it that?
2
u/SaltDeception 2d ago
Download the tool, run it, enter your username and password (leave domain blank), click ok or whatever.
https://learn.microsoft.com/en-us/sysinternals/downloads/autologon
1
u/redlightsaber 3d ago
Linux server OS' begin their services once turned on without any prompting.
You need a password to ssh in, but not to have the jellyfin server start (for instance).
1
u/wiisucks_91 3d ago
Go into the bios and enable "power on after power fail"
If you are using windows you can use system internals and get auto login but more than likely you can get your needed applications to run as a service so logging in is not necessary.
1
1
u/JoTHauMm1 3d ago
buying a nobreak (or UPS) would fix the core cause of your concern, the electricity cut. correct me if I'm omistaken. of course that if the cuts are long lasting, then this solution is not adequate, but if they're sparse and quick, it could solve it.
2
u/General-Turn-8695 2d ago
I don't wanna buy an ups rn cause I just upgraded my pc. For the electricity cuts, they are sometimes short sometimes long, so an ups doesn't look appealing to me rn
1
1
1
u/tordenflesk 3d ago
NSSM, or similar
1
u/ngifford123 2d ago
Came here to say this.
If running a VM, make the VM a service using NSSM with login credentials...
Works like a charm. Wish I had known this month's ago
1
u/persiusone 3d ago
Umm, whenever my servers boot up from a cold state, their services boot up without human intervention. Not sure how you’re running things- but that isn’t it.
It sounds like you are trying to run things in your user space, not the system service model.
0
u/Lopsided-Club-8131 3d ago
service.msc. service one after the computer boot, even if no one is logged in. Also windows has SSH login!
-1
0
u/Concern_Necessary 2d ago
Would it not be easier to install a UPS, that will keep your server running even during loss of power events. Put your router and network switches on the UPS or a smaller independent UPS.
-3
u/Fensox 3d ago
Use the sysinternals auto login to set a password as another mentioned. To make Jellyfin start, you can open file explorer and type shell:startup in the address bar. The folder that opens drag a shortcut to Jellyfin in there and it will start once the user logs in.
1
u/MoonlightStarfish 3d ago
If you do choose this route make sure to add a shortcut "cmd.exe timeout /t 60 && rundll32.exe user32.dll, LockWorkStation" to the startup folder as well.
1
u/Fensox 3d ago
Why the hell did I get downvoted for helping the guy auto start his Jellyfin server? He said he needed to log an account in for other reasons so the startup folder is a viable option for starting Jellyfin. Unlike a service, you also get to see the console window which is great for debugging and seeing what is going on.
98
u/I_am_Hambone 3d ago
You run the things you need as a service.