rebooting an OS X machine remotely

MFiend

Registered
Hi, I have a problem where my OS X server is far away from me and I'm having to login to it remotely.
This is fine and all, but I installed some software on it and I need to restart. I tried using the shutdown -r now command while logged in through ssh, but that just seems to have brought it to some single user commandline state, where the SystemUIServer, nor my Apache2 install, are running.
Is there something I can do to bring the machine back up to a full gui login, or do I just have to wait until I can get back to the machine in a few days?

Thanks
 
Try:

% sudo reboot

I always manage to reboot the system once it's already in single-user mode doing that, without the sudo of course, but I presume if a system is already up in multi-user mode it won't let any joe issue reboot or halt.
But since my system is running, I won't test it myself just now.

REBOOT(8) System Manager's Manual REBOOT(8)

NAME
reboot, halt - stopping and restarting the system

SYNOPSIS
halt [-nqd]
reboot [-nqd]

DESCRIPTION
The halt and reboot utilities flush the file system cache to disk, send
all running processes a SIGTERM (and subsequently a SIGKILL) and, respec-
tively, halt or restart the system. The action is logged, including
entering a shutdown record into the login accounting file.

The options are as follows:

-n If the -n option is specified, the file system cache is not
flushed. This option should probably not be used.

-q If the -q option is specified, the system is halted or restarted
quickly and ungracefully, and only the flushing of the file sys-
tem cache is performed. This option should probably not be used.

-d If the -d option is specified, the system will create a dump
before rebooting. This option is useful for debugging system
dump procedures or capturing the state of a corrupted or misbe-
having system.

Normally, the shutdown(8) utility is used when the system needs to be
halted or restarted, giving users advance warning of their impending
doom.

SEE ALSO
sync(1), utmp(5), boot(8), shutdown(8)

If you want I can SSH into your system and try it out :p
 
PS if your system is multi-user (and you have the possibility of other users being logged in when you need to reboot) I'd do a % sudo wall and tell them the system's going down, because I don't believe reboot sends out messages to all the terminals like shutdown(8) does.

% shutdown -r is supposed to execute reboot(8) as well, but maybe there's something going on that prevents your system actually rebooting, like a firmware issue or something convoluted? :confused:
 
But don't users have to have the Terminal open to see the message when you do %sudo wall

Is there a way to make the message pop up in the aqua interface where most users are probably working?
 
nope, that still didn't work. here is a ps listing of what's going on right now. as stated, there is no SystemUIServer, Finder, or httpd, or anything that should be running if it were booted up through the gui login, as it should do automatically. I'm pretty much as a loss as to what to do until I can get back to physical access.

PID %CPU %MEM USER COMMAND
1 0.0 0.0 root init
2 0.0 0.0 root mach_init
51 0.0 0.1 root kextd
78 0.0 0.0 root update
82 0.0 0.0 root dynamic_pager
110 0.0 0.2 root configd
141 0.0 0.1 root SecurityServer
181 0.0 0.2 daemon ATSServer
185 0.0 1.0 root Window Manager
194 0.0 0.0 root autodiskmount
252 0.0 0.0 root syslogd
264 0.0 0.0 root crashreporterd
268 0.0 0.0 root netinfod
271 0.0 0.1 root mDNSResponder
275 0.0 0.1 root lookupd
297 0.0 0.2 root coreservicesd
301 0.0 0.0 root sshd
306 0.0 0.0 root nfsiod
307 0.0 0.0 root nfsiod
308 0.0 0.0 root nfsiod
309 0.0 0.0 root nfsiod
319 0.0 0.0 root ntpd
320 0.0 0.1 root automount
330 0.0 0.0 root inetd
334 0.0 0.3 root cupsd
336 0.0 0.0 root xinetd
346 0.0 0.5 root loginwindow
348 0.0 0.0 root cron
362 0.0 0.4 root DirectoryService
363 0.0 0.1 root sshd
382 0.0 0.1 root AppleFileServer
387 0.0 1.8 root SecurityAgent
392 0.0 0.0 root InternetSharing
394 0.0 0.0 root natd
397 0.0 0.0 root bootpd
399 0.0 0.1 root slpd
401 0.0 0.1 acooper sshd
408 0.0 0.0 root write_store
402 0.0 0.1 acooper tcsh
411 0.0 0.0 root ps
 
MFiend,

did you specify the file with the message that you wanted displayed?

For example:
%sudo wall /users/home/adminmessage

You can easily create the file in Pico. The only draw back which i can see is that the message is only displayed in the terminal. So, make sure you have a separate window for terminal open.
 
The message sent to logged in users is not the problem. I am the only logged in user to my machine.
The problem is that, upon "restarting", the machine does not fully boot. By fully boot I mean it does not log in the default user (me) in the gui, and launch all the login items for that user, start the SystemUIServer, Finder, etc. so that I can use something such as vnc to control the machine remotely. I just boots to some in between point where many things are running, but it is obviously waiting for some physical input which I cannot provide remotely.
 
Are you using Apple's Remote Desktop?

If so I suggest downgrading to 1.0. In the update they made it so you had to have someone logged it before you could access the machine. They considered it a security flaw. I consider it a pain in the arse.
 
no, I'm just using ssh to login via an external machine. nothing so fancy as apple remote desktop
 
MFiend, can you determine which of the following the machine is doing?

1) Rebooting into single user mode; or
2) Just going down to single user mode.

If it's doing the former, you might have something wonky in NVRAM (boot-args).

And can you restart successfully, locally, with an open shell window?

dixonbm, the problem is just rebooting properly, but as for Aqua messages, I'm sure there's a way to make an AppleScript to display pop-up messages for each logged user. But since it's only a terminal window we're concerned about, we don't have to worry about that :p
 
MFiend - can you telnet rather than ssh? Maybe ssh doesn't allow a reboot (I dunno about that one, but it's something to try).
 
MFiend... it looks to me, from your process listing, that its rebooting to the Login window... I would guess that its rebooting fine but just not doing the auto login (if you have that enabled).

As for why httpd doesn't come up... I would check your start-up items to make sure you have it configured properly.
 
Ah nuts! Of course, System UIServer only starts once a user logs in.

I thought about the auto-login thing but dismissed it since SUIS wasn't running...

Good eye.
 
that's kinda what I had figured too, but is there a way to make the computer log in?
I wonder if maybe my httpd issues have to do with that I installed apache2 and that might not start until login, unlike personal web sharing (apache 1).
 
Yeah it in System Preferences -> Login you select the user to automatically log in and provide the information.

If your computer is at all public (physically I mean) I'd suggest creating a user with almost no privileges that it boots into, so people can't mess around with your machine when it reboots. Or otherwise enable a password-protected screensaver to start after a short delay (you can then use top or ps to make sure it's running).
 
well, it should be set to automatically log in, as that's what it does when I restart it from the gui. but the problem is that it didn't log in when I restarted through ssh
 
right, and I need a way to remotely make the machine log in locally, if that makes sense. I want the machine to pretend as if I'm actually sitting there logging in through the gui
 
:p

Ok here's something to try, but I would do this very cautiously!

What I'm trying to achieve by doing this, is to see if rebooting as the root user is equivalent to rebooting from the console, which will auto-log you in, since you said you enabled auto-login.

If you have disabled the root user in Netinfo, re-enable it (Netinfo Manager -> Authenticate -> Domain -> Security -> Enable Root User).

In the terminal
% sudo pico /etc/sshd_config

Change:
PermitRootLogin no
... to ...
PermitRootLogin yes

Then make inetd notice the change:
% sudo kill -HUP `cat /var/run/inetd.pid`

Then log in over SSH as root and try rebooting.

I don't suppose I have to go into how big of a hole you've just opened in your system :rolleyes: but at least you'll know if THAT works. If it does, we can work backward from there...

PS The config files might be different in 10.2 I'm not sure, and I think 10.2 uses xinetd, so someone with Jag might have to update my code snippits to work properly.
 
Back
Top