Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
SSH'ing into a.. suspended system?
View unanswered posts
View posts from last 24 hours

Goto page 1, 2  Next  
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
yuuki102
n00b
n00b


Joined: 21 Sep 2021
Posts: 27

PostPosted: Tue Sep 21, 2021 12:10 pm    Post subject: SSH'ing into a.. suspended system? Reply with quote

Hi all,

I have finished installing and configuring a "server" (It's just a plain-old LGA 775 system, P5KPL-AM motherboard) with Open-RC Gentoo, and I'm very happy with it overall, it will certainly prove itself useful.

But I don't use it all the time, so I can't have it on 24/7 wasting precious power that can be used for something else, so I thought about how I can wake the system remotely when I need it. Then, a past experience I had, gave me an idea.

A number of years ago, when I was making a discord bot for the fun of it, I was running it on my main PC for testing. The morning I left for College, I put my PC in suspended mode to save power, and took off to College. During break time, I noticed that my bot was still up, so I thought that this was just some dumb glitch, which is why I was shocked when I sent a command and it responded. The bot, on my suspended system, was still running perfectly. I realized that ATX PSUs have a 5v Standby rail, which was probably what the CPU was using to still execute instructions.

Therefore, my question is this: Is this possible to achieve with my Gentoo server? I obviously don't expect to make use out of it during sleep, I just want to be able to SSH to it all the time, which will also give me the ability to manually wake it via SSH.

So? Is this possible? It's probably not with the legacy suspended S1 and S3 states BIOS supports, but maybe it's possible with newer UEFI-based motherboards.

And before you mention Wake on LAN, I am aware of what it is. My idea seems way more convenient, which is why I want to explore it.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Tue Sep 21, 2021 1:48 pm    Post subject: Reply with quote

No you'll have to leave it on else you'll have to make your router or whatever automatically send WoL and hope that same router does not drop connection during downtime. You got lucky on your previous experience that routers along the way (if any) didn't drop state - machines in suspend do not run instructions at all.

Either way it's very annoying not to simply leave it on, if not just waiting for the machine to resume.

"Connected suspend" for Windows is something else, don't think Linux supports it, especially on older hardware. This is not the usual S-states and standby power is not really enough to power standard PCs with it, at least enough to keep ssh going - it was meant for "phone" and "tablet" type computers. BTW, yes M$ uses connected suspend to zombie your computers to do updates when it's "off" so you never know when it's truly "off".
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3264
Location: Canada

PostPosted: Tue Sep 21, 2021 7:02 pm    Post subject: Reply with quote

How large is your power consumption in idle mode ? Perhaps you could work on reducing that to bare minimum ?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21490

PostPosted: Tue Sep 21, 2021 7:59 pm    Post subject: Re: SSH'ing into a.. suspended system? Reply with quote

yuuki102 wrote:
A number of years ago, when I was making a discord bot for the fun of it, I was running it on my main PC for testing. The morning I left for College, I put my PC in suspended mode to save power, and took off to College. During break time, I noticed that my bot was still up, so I thought that this was just some dumb glitch, which is why I was shocked when I sent a command and it responded. The bot, on my suspended system, was still running perfectly.
As most people understand the term "suspend", this cannot happen. A system in S3 idles the CPU and does not run any user processes. A system in S5 writes system state to disk, then halts. If your bot was responsive, then somehow your computer was not actually suspended in the sense we typically mean. Either it was woken up after you left, never entered suspend at all, or the suspend you used is not what we typically mean.
yuuki102 wrote:
Is this possible to achieve with my Gentoo server? I obviously don't expect to make use out of it during sleep, I just want to be able to SSH to it all the time, which will also give me the ability to manually wake it via SSH.
Per above, the sshd cannot respond while the system is sleeping. Supposing for the sake of argument that it could, how would you remotely wake the system after you ssh in?
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3264
Location: Canada

PostPosted: Tue Sep 21, 2021 11:39 pm    Post subject: Re: SSH'ing into a.. suspended system? Reply with quote

Hu wrote:
Supposing for the sake of argument that it could, how would you remotely wake the system after you ssh in?


Well, one could be thinking about Wake-On-Lan as discussed before (of course, the wake comes before ssh anyway), right ?
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3264
Location: Canada

PostPosted: Tue Sep 21, 2021 11:43 pm    Post subject: Reply with quote

eccerr0r wrote:
No you'll have to leave it on else you'll have to make your router or whatever automatically send WoL and hope that same router does not drop connection during downtime. You got lucky on your previous experience that routers along the way (if any) didn't drop state - machines in suspend do not run instructions at all.

Either way it's very annoying not to simply leave it on, if not just waiting for the machine to resume.

"Connected suspend" for Windows is something else, don't think Linux supports it, especially on older hardware. This is not the usual S-states and standby power is not really enough to power standard PCs with it, at least enough to keep ssh going - it was meant for "phone" and "tablet" type computers. BTW, yes M$ uses connected suspend to zombie your computers to do updates when it's "off" so you never know when it's truly "off".



Isn't there something like that (was it Sleep Proxy ? ) from Apple as part of bonjour, which is, in principle, open sourced ?

Also, with WoL, you can try to sent WoL from a computer on the local network, without intermediate routers, if you have some 24/7 one on your local network.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Tue Sep 21, 2021 11:59 pm    Post subject: Reply with quote

Once again it's a software-hardware problem. It depends on the Ethernet card too, perhaps the ethernet card can automatically detect without the OS that a packet was destined to the machine and then send the wake event to itself. Would need a very stateful card with complex drivers.

Still would have wakeup latency and that packet probably needs to be eaten so there would be a retry that needs to happen.

I suspect the OP does not have any other machines on the network to sniff for packets destined to the ssh box other than the router, plus any switches along the way would break that real fast. Router would be the logical choice.

Then the other problem of when the machine needs to go back down coupled with junk that circulates on the network and whether they should trigger wake events...
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21490

PostPosted: Wed Sep 22, 2021 1:12 am    Post subject: Re: SSH'ing into a.. suspended system? Reply with quote

dmpogo wrote:
Hu wrote:
Supposing for the sake of argument that it could, how would you remotely wake the system after you ssh in?
Well, one could be thinking about Wake-On-Lan as discussed before (of course, the wake comes before ssh anyway), right ?
Yes, Wake-On-Lan is the usual solution to this. As I interpreted the opening post, OP explicitly believes this is not Wake-On-Lan as usually understood, but some special state where the system is asleep, yet responsive.

One way to achieve that would be to spin down all hard drives, freeze all non-essential user processes, and use a NO_HZ_FULL kernel to minimize timer ticks. Even there, the hardware would be mostly awake, so power savings would be questionable.
Back to top
View user's profile Send private message
dmpogo
Advocate
Advocate


Joined: 02 Sep 2004
Posts: 3264
Location: Canada

PostPosted: Wed Sep 22, 2021 7:58 am    Post subject: Re: SSH'ing into a.. suspended system? Reply with quote

Hu wrote:
Even there, the hardware would be mostly awake, so power savings would be questionable.


That may be depends on hardware (and OP hardware is old, so you are probably right). On modern laptops when idle CPU goes into low P state, power consumption is quite lowered.
Back to top
View user's profile Send private message
C5ace
Guru
Guru


Joined: 23 Dec 2013
Posts: 472
Location: Brisbane, Australia

PostPosted: Wed Sep 22, 2021 10:46 am    Post subject: Reply with quote

yuuki102:

My neighbors home system uses
FRITZ!Box 7590 (Router, Dect Base Station, VOIP Router)
FRITZ!DECT 200 (Power switches)
SMARTPHONE or Office PC
to remotely switch on and off his air conditioner, coffee maker and washing machine from his smartphone.
_________________
Observation after 30 years working with computers:
All software has known and unknown bugs and vulnerabilities. Especially software written in complex, unstable and object oriented languages such as perl, python, C++, C#, Rust and the likes.
Back to top
View user's profile Send private message
yuuki102
n00b
n00b


Joined: 21 Sep 2021
Posts: 27

PostPosted: Thu Sep 23, 2021 11:35 am    Post subject: Reply with quote

Quote:
How large is your power consumption in idle mode ? Perhaps you could work on reducing that to bare minimum ?


When idle, it's about 100-150W, like most modern ATX computers. This is why that one new ATX standard that has DC-DC conversations on the motherboard is worked on, idle consumption on the ATX platform is quite bad.

Quote:
As most people understand the term "suspend", this cannot happen. A system in S3 idles the CPU and does not run any user processes. A system in S5 writes system state to disk, then halts. If your bot was responsive, then somehow your computer was not actually suspended in the sense we typically mean. Either it was woken up after you left, never entered suspend at all, or the suspend you used is not what we typically mean.


Except that it was, by the time I came back, I confirmed that it was off. The PSU was not running, but the bot was. A user above explained that this is some kind of "Connected Suspend" Windows has, which is something Linux doesn't (because it has no reason to) support.

Quote:
Also, with WoL, you can try to sent WoL from a computer on the local network, without intermediate routers, if you have some 24/7 one on your local network.

This is what I ended up doing, I setup WoL. It's mostly good enough anyway.

Quote:
Once again it's a software-hardware problem. It depends on the Ethernet card too, perhaps the ethernet card can automatically detect without the OS that a packet was destined to the machine and then send the wake event to itself. Would need a very stateful card with complex drivers.


Is there really such a thing? I'd be surprised.

Quote:
I suspect the OP does not have any other machines on the network to sniff for packets destined to the ssh box other than the router, plus any switches along the way would break that real fast. Router would be the logical choice.


I do have a 24/7 rPI. Your post gives me the idea to some write some kind of SSH routine in the Pi that would send a WoL magic packet when I try to ssh into a machine. I've no idea how I would approach such a solution though...

Quote:
Yes, Wake-On-Lan is the usual solution to this. As I interpreted the opening post, OP explicitly believes this is not Wake-On-Lan as usually understood, but some special state where the system is asleep, yet responsive.

One way to achieve that would be to spin down all hard drives, freeze all non-essential user processes, and use a NO_HZ_FULL kernel to minimize timer ticks. Even there, the hardware would be mostly awake, so power savings would be questionable.


Yes, the Windows system was completely off, even the power supply (Obviously, the 5v STANDBY rail was not). This is what I wanted to go for, but it doesn't look possible.

Either way, I have setup WoL so I'm happy with this for now. Thank you all for the replies.
Back to top
View user's profile Send private message
mike155
Advocate
Advocate


Joined: 17 Sep 2010
Posts: 4438
Location: Frankfurt, Germany

PostPosted: Thu Sep 23, 2021 12:09 pm    Post subject: Reply with quote

yuuki102 wrote:
When idle, it's about 100-150W, like most modern ATX computers.

Wait... The wattmeter shows 20W for my new desktop machine (Ryzen 3 5700G CPU, ASUS TUF Gaming B550-Pro, 64GB RAM; Samsung SSD) in idle mode. 100-150W in idle mode is much too high for modern computers.
Back to top
View user's profile Send private message
yuuki102
n00b
n00b


Joined: 21 Sep 2021
Posts: 27

PostPosted: Thu Sep 23, 2021 1:16 pm    Post subject: Reply with quote

Quote:
Wait... The wattmeter shows 20W for my new desktop machine (Ryzen 3 5700G CPU, ASUS TUF Gaming B550-Pro, 64GB RAM; Samsung SSD) in idle mode. 100-150W in idle mode is much too high for modern computers.


Your system is much newer than mine though, we are talking about a LGA775 Core 2 Quad system from 2009 over here with a crappy no-brand PSU! Yeah, you are right, 150W idle is too much for modern systems. My bad! But that's just the case for me. It does work fine though, it has been for about 6 years since I've owned it. That isn't to say no-brand PSUs are good, of course, I really should replace that thing at some point :P That'll probably help the idle power consumption.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Thu Sep 23, 2021 2:58 pm    Post subject: Reply with quote

not sure what video card you have but if you have a complex GPU it will be drawing power that you can't use remotely anyway.
I still run two S775 machines 24/7, yeah they eat power but not really that bad. Neither have discrete GPUs.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
yuuki102
n00b
n00b


Joined: 21 Sep 2021
Posts: 27

PostPosted: Thu Sep 23, 2021 4:53 pm    Post subject: Reply with quote

GeForce GT 610, that's my video card. I use this instead of the integrated graphics because:
a) They are hard-broken (Red lines across the screen, even in BIOS)
b) They eat much needed memory (P5KPLM-AM has max 6GB support)
c) It's 4 years more modern than the rest of the system, so xorg works flawlessly with nouveau (I do use graphics using a VNC server over an SSH tunnel).

I should honestly invest in a better LGA 775 mobo. It's an old system, yes, but it's actually enough for my needs. The mobo is my very first, and is from my childhood (when I was 9), so it has grown a little problematic both with the onboard graphics and recently failure in recognizing one of the memory slots.
Back to top
View user's profile Send private message
szatox
Advocate
Advocate


Joined: 27 Aug 2013
Posts: 3104

PostPosted: Thu Sep 23, 2021 5:11 pm    Post subject: Reply with quote

Well, many mobos feature wake-on-lan.
Wake on lan allows you to start your PC with a magic packet containing ethernet interface's MAC address repeated a bunch of time.
Linux supports hibernation AKA suspend-to-disk.

So.... You could try to boot a hibernating machine via WOL and then ssh into it. Obviously, you need a device on the same LAN that can send that WOL packet.
Technically there is no reason why it couldn't work with suspend-to-ram as well, though it's NOT this feature's default purpose, so it may or may not be implemented.

Just sayin'.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Thu Sep 23, 2021 5:15 pm    Post subject: Reply with quote

Well if you must keep power down, the GPU needs to be jettisoned if you're not using it to mine cryptocurrency or FAH anyway.
The onboard graphics memory sharing is minor and if you're not in graphics mode, it's a drop in the bucket. I set mine really low as I don't do 3d graphics on them - one is a PVR and was meant to watch TV on it, other is a general purpose server and I seldom use graphics mode, recently only to much with the libvirt GUI. (but yeah, 6GB on a quad core for Gentoo is a bit tight if you want to use -j4 building qtwebengine...)

Granted if it's broken, it's broken, can't do much about that. But if you don't use console and that worried about power usage, you're better off removing the discrete GPU.

szatox, I think the OP has a problem generating the WoL packet remotely, that's the main problem here. Apparently the ideal situation is for any packet including an ssh packet to wake the machine not just WoL... and be screwed by the ssh hackers out there that pound peoples machines.

OP: I get on average one or two every minute even after evasive maneuvers (the worst period of time I was getting one every 3 seconds), so that will pretty much keep your machine on all the time anyway.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
yuuki102
n00b
n00b


Joined: 21 Sep 2021
Posts: 27

PostPosted: Thu Sep 23, 2021 7:06 pm    Post subject: Reply with quote

eccerr0r wrote:
Well if you must keep power down, the GPU needs to be jettisoned if you're not using it to mine cryptocurrency or FAH anyway.
OP: I get on average one or two every minute even after evasive maneuvers (the worst period of time I was getting one every 3 seconds), so that will pretty much keep your machine on all the time anyway.


Is it really that bad? Why do people even bother to attack random servers on the Internet?

I don't feel very confident in my Cyber Security skills (The thought of port forwarding is making my bones shake a little) so I keep everything confined within the safety of my little network, which is behind a NAT and a firewall.

To clarify, the server is within the house. I just need to be able to access it and wake it from my main machine without having to physically go back and forth. I don't want to access it over the Internet, although this is something I have been considering, but the brute-forcing attempts you get scare me. People are out there for blood :/

Like I have explained above though, I got the machine to work with WoL very nicely, even on suspend mode. The original SSH into suspended CPU stunt I wanted to do just seemed cooler than WoL and I wanted to explore it. Kind of like having a server with a low power state (suspended mode) and full power mode (When I wake it). But I understand now that this is impossible for the reasons discussed here, so I just WoL and ssh once it has awaken. It's totally fine :D!

Maybe someday I'll port forward SSH as well.
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Thu Sep 23, 2021 7:19 pm    Post subject: Reply with quote

If you're not allowing over the internet and local only, then you can WoL it and your problem is solved, you know when you want to use it and you're close enough (i.e. on the LAN) to send the packet or even physically walk there to turn on. No problem or you're just lazy.

If you want over the internet access anywhere anytime when it's much more inconvenient to walk/drive/fly home and turn it on, then you have to deal with the hacking. At 1 attempt per minute, the chance of getting hacked is very, very low - even lower if you filter these too (the 1 per minute that I get on average, most of these are filtered and they don't really get an attempt - but I still log them to understand the nature of the attacks.)
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20054

PostPosted: Thu Sep 23, 2021 11:18 pm    Post subject: Reply with quote

eccerr0r wrote:
"Connected suspend" for Windows is something else, don't think Linux supports it, especially on older hardware. This is not the usual S-states and standby power is not really enough to power standard PCs with it, at least enough to keep ssh going - it was meant for "phone" and "tablet" type computers. BTW, yes M$ uses connected suspend to zombie your computers to do updates when it's "off" so you never know when it's truly "off".
I've searched for windows connected suspend and all I'm seeing are results related to USB selective suspend. If I quote "connected suspend" in the search, this thread seems to be the most relevant result. Any chance you have more details on what this is or how it works? Obviously software doesn't run without electricity, so I'm guessing there is some low resource utilization mode. That something other than a core service could run in this mode is both interesting and concerning.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Thu Sep 23, 2021 11:45 pm    Post subject: Reply with quote

I might have the wrong term, but it was something like that. Don't remember exactly what the term is, but these specific machines were designed with SOC processors based on ultra low power CPUs (specifically atom) and designed to suspend/resume *very* fast, so fast that it can use it as a sleep state when the machine is idle for any reason including waiting for the next packet to arrive.

Ultimately it was meant for tablet/phone Windows that can suspend/resume so fast it's like unlocking a cell phone, except it's x86. Plus you get (most) of the battery savings just like a cell phone.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
yuuki102
n00b
n00b


Joined: 21 Sep 2021
Posts: 27

PostPosted: Fri Sep 24, 2021 12:06 am    Post subject: Reply with quote

pjp wrote:
eccerr0r wrote:
"Connected suspend" for Windows is something else, don't think Linux supports it, especially on older hardware. This is not the usual S-states and standby power is not really enough to power standard PCs with it, at least enough to keep ssh going - it was meant for "phone" and "tablet" type computers. BTW, yes M$ uses connected suspend to zombie your computers to do updates when it's "off" so you never know when it's truly "off".
I've searched for windows connected suspend and all I'm seeing are results related to USB selective suspend. If I quote "connected suspend" in the search, this thread seems to be the most relevant result. Any chance you have more details on what this is or how it works? Obviously software doesn't run without electricity, so I'm guessing there is some low resource utilization mode. That something other than a core service could run in this mode is both interesting and concerning.


I was shocked as well, but it really did happen. It was on a 7th gen Intel system that I don't have anymore running Windows. The bot in question was a Discord bot I wrote in Python, and I remember which command I wrote when I discovered it was still processing commands through my suspended system. I tried to go through the chat history to find it just so I can show you how much I was freaking out, but I issued that same command along with my friends hundreds of times so it's hard to pinpoint the point in time from that alone.

What happened and how I don't know. But I always assumed that the CPU was sitll powered in a lower state or something from the 5v STANDBY rail in the power supply, so it made sense in my head. FOr the record, when I went home, I confirmed that my computer was still suspended and I even tested it out afterwards. I do still have the bot, and I guess I could install WIndows in a spare drive or something to test it out, but I doubt the API is the same as back then. I don't have the patience to tweak my old bot justo test out something form an OS that I won't even use :P
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Fri Sep 24, 2021 12:18 am    Post subject: Reply with quote

ATX computers cannot run from 5VSB. It must have needed to be outside of S3 suspend to process packets. There is a chance there's something that will wake the machine fully out of suspend.

It's different for atom SOCs as they were designed for battery operation and needed a state where it can shut everything down and spring back when a phone call comes in or when someone pushes the wake button to dial.

Whether they're making all machines now have this type of instant suspend or not is another question... but it's a lot of hardware to make sure it all supports power being shut off. It's a bit easier for a single SOC where it's known what's inside the SOC or not.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
pjp
Administrator
Administrator


Joined: 16 Apr 2002
Posts: 20054

PostPosted: Fri Sep 24, 2021 12:33 am    Post subject: Reply with quote

Thanks. I'm surprised it hasn't caught on. Although I suppose it has minimal use. Still, for an update server or a low usage service, it could be a nice option to reduced power usage in the home.
_________________
Quis separabit? Quo animo?
Back to top
View user's profile Send private message
eccerr0r
Watchman
Watchman


Joined: 01 Jul 2004
Posts: 9645
Location: almost Mile High in the USA

PostPosted: Fri Sep 24, 2021 12:44 am    Post subject: Reply with quote

Note that PCIE does not get +5VSB, so this type of "instant suspend" won't work for machines with add-on PCI cards like video cards.
_________________
Intel Core i7 2700K/Radeon R7 250/24GB DDR3/256GB SSD
What am I supposed watching?
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Goto page 1, 2  Next
Page 1 of 2

 
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