Quantcast
Viewing latest article 3
Browse Latest Browse All 18

How to remotely sleep a Mac using another one with SSH login

The SSH is a little gem for OS X feels-like-hacker users. It allows you to remotely connect to your Mac using another one by entering username and password, in order to access to the system. In this tutorial, we’re going to see how to sleep a Mac using SSH login from Terminal. First of all, you need to enable SSH login on the computer you want to sleep. Just go to System Preferences > Sharing and tick the Remote Login option.

Open the Terminal and type the command using this syntax:

ssh [username]@[IP address]

Replace the [username] with your account username on the computer you want to sleep. If you’re not sure about which is your username, hit Shift+Cmd+H and see your home folder name. Then type its IP address. You can find it in System Preferences > Network, then look at the IP field. Execute the command and, when asked from the Terminal, type “yes” to confirm that you want to connect to the host creating a RSA key.

At this point, you should get something like this: (for security reasons, usernames, IP addresses and RSA key won’t be showed)

Image may be NSFW.
Clik here to view.
SSH Login from Terminal

Enter then the password to get full access to your account remotely. Once done, type

osascript -e 'tell application "System Events" to sleep'

Now you Mac should sleep automatically! If you have any question, feel free to ask using the comments.

 

In Italiano

L’SSH è una piccola gemma per gli utenti più esperti di OS X. Permette infatti di collegarsi in remoto ad un altro computer, utilizzando un semplice comando dal Terminale. In questa guida vedremo come mandare in Stop il Mac, utilizzandone però un’altro. Per prima cosa, dovete abilitare il login SSH sul primo di questi. È possibile farlo andando su Preferenze di Sistema > Condivisione e spuntando l’opzione Login Remoto. Segnatevi quindi l’indirizzo IP del computer (visibile da Preferenze di Sistema > Network nel campo “Indirizzo IP”) e il nome utente. Se non siete sicuri su quale sia, premete Shift+Cmd+H e guardate il nome della cartella utente.

Andate quindi sul Terminale, e digitate il seguente comando utilizzando questa sintassi:

ssh [nome utente]@[indirizzo IP]

Vi verrà quindi chiesto conferma di voler creare una chiave RSA univoca; per farlo, digitate “yes” e premete invio. Alla fine, dovrete inserire la password dell’account al quale volete connettervi.

Ora che la connessione è stata stabilita con successo, eseguite il comando seguente:

osascript -e 'tell application "System Events" to sleep'

Ecco allora che il Mac andrà automaticamente in stop, pronto per riavviarsi appena decidiate di usarlo.


Filed under: Tutorial Tagged: Apple, Mac, OS X, SSH, Terminal, Tutorial Image may be NSFW.
Clik here to view.
Image may be NSFW.
Clik here to view.

Viewing latest article 3
Browse Latest Browse All 18

Trending Articles