Can I restart my Mac remotely via screen sharing if the screen shows only linen?
-
14-12-2020 - |
質問
I am currently in Norway. My Mac mini is in my apartment in Australia. I can access screen sharing via Back To My Mac. It connects fine, but the screen has only linen - no menu bar, no dock, no anything else. I am fairly sure that is what is actually on the screen and that it isn't a problem with the connection or anything like that (it's happened once before while I was sitting in the same room...)
I know the system is responsive because the one other thing that can poke through my router is the Transmission web interface, and that works just fine. (Unfortunately I seem to have neglected to forward a port for ssh...)
Is there any way I can reboot or otherwise regain full use of the system via the limited screen sharing access that I have?
解決
So apparently you can use the Back To My Mac infrastructure to get to SSH even if there's no port open on the router in front of the relevant Mac:
Find your iCloud account number by executing this command in terminal:
dns-sd -E
Example output
Looking for recommended registration domains:
Timestamp Recommended Registration domain
23:45:15.660 Added (More) local
23:45:15.660 Added icloud.com
- > btmm
- - > members
- - - > 123456789
(Make a note of the number on the last line, in this case 123456789 (this is just an example).
The hostname you need to use for ssh is <computer's local hostname>.<number above>.members.btmm.icloud.com. Replace spaces with hyphens, and omit apostrophes (the default name is "Name's <type of Mac>")
The command I used therefore was:
ssh -2 -6 Jons-mac-mini.123456789.members.btmm.icloud.com
To complete the solution to my problem (rebooting), once logged in via SSH, I used the following command to restart:
sudo /sbin/shutdown -r now
(Sourced from here)
他のヒント
In this page says that Control-Eject show you a shutdown dialog. (You need a keyboard with an eject key.)
If you want to remotely restart the machine without having to specify the user then you can specify an input file in the form of a plist. Do the following steps on the computer that you are remoting into:
First you need to create a plist file that will have your credentials, open up a terminal window and paste the following:
touch ~/.restart.plist
. Now open up that plist file in a text editor and paste the following:<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>Username</key> <string>USERNAME_HERE</string> <key>Password</key> <string>PASSWORD_HERE</string> </dict> </plist>
- Replace USERNAME_HERE and PASSWORD_HERE in the file above with your credentials and save the file.
- Create an alias in your bash profile so that all you
have to do is type
reboot
and it will do the rest for you. Open up your ~/.bash_profile in a text editor and add the linealias reboot="sudo fdesetup authrestart -inputplist < ~/.restart.plist"
then save the file. - Close and reopen your terminal window, or type in
source ~/.bash_profile
in order to update your alias to match the bash profile.
Now you'll be able to restart your remote computer with a specific user just by typing reboot
into your terminal!