Assuming that the user you are going to use in remote.host is the same you use in local.host
In order to do that you have to first authorize your local.host to connect to you remote.host with no password.
To do that you have to: (as described here)
Step 1: Install ssh
sudo apt-get install ssh
Step 2: Create public and private keys using ssh-key-gen on local-host
On your local host, enter this command:
ssh-keygen
You should save the generated key in:
/home/yourusername/.ssh/id_rsa
Press enter twice to leave the passphrase empty.
Your identification has been saved in /home/yourusername/.ssh/id_rsa.
Your public key has been saved in /home/yourusername/.ssh/id_rsa.pub.
The key fingerprint is:
XX:XX:XX:xX:XX:xX:XX:XX:XX:XX:XX:XX:XX:XX yourusername@local-host
Step 3: Copy the public key to remote-host using ssh-copy-id
yourusername@local-host$ ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host
yourusername@remote-host's password:
Now try logging into the machine, with "ssh remote-host", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
Note: ssh-copy-id appends the keys to the remote-host’s /home/yourusername/.ssh/authorized_key
Step 4: Login to remote-host without entering the password
ssh remote-host
yourusername@remote.host:~$
Access to remote-host with no password. Success!
Now you have to be able to execute the sudo shutdown -P 0 with no password.
Modify /etc/sudoers on remote.host with visudo
That way user "yourusername" can execute the shutdown command with no password asked.
Login to the remote host.
ssh remote.host
Run:
sudo visudo
By running visudo, it leads to edit /etc/sudoers.
Adding the line below to that file.
yourusername ALL = NOPASSWD: /sbin/shutdown
Done that, get back to your local.host
Create a new empty file and paste this line, modifying the remote.host's name
ssh remote.host sudo shutdown -P 0
Save and close it, go to it's Properties slide to Permissions, and tic the execute this file as a program
Script Done!
This is a configurable option in the XFCE Power Manager, which was installed by default in my relatively fresh Lubuntu 14.04.1 installation (a laptop). I found it at Preferences > Power Manager. If it's not installed already for you, you should be able to install it with sudo apt-get install xfce4-power-manager
In "General Options", you'll want to select "When power button is pressed: Shutdown" (default setting is "Ask" - which brings up the popup menu you want to skip). See the starred line in the image below.
I needed to log out of Lubuntu and log back in for this setting to take effect, but after that, one press of the power button shut down my system.
Hope this works for you!
Best Answer
Clicking on the shutdown button with your mouse is equivalent to calling
gnome-session-quit
: