ViolentMonk
Posts: 35
Joined: Mon Jul 22, 2013 8:36 am

turn off one pi from another?

Wed Aug 07, 2013 10:15 pm

I was wondering if I could in some way turn off a pi running raspbian using a pi with openelec so I don't have to turn my pc on just to turn it off. also as a last resort how well does an IR sensor work with raspbian? I got one working with openelec but I don't want build a second IR if theres another way.

W. H. Heydt
Posts: 14414
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: turn off one pi from another?

Thu Aug 08, 2013 5:50 am

Use ssh (or PuTTY) to get from one Pi to the other. Issue the shutdown command. Done.

I occasionally do that (though both Pis are running Raspbian). More commonly I use on Pi to shut down a particular process on the other.

ViolentMonk
Posts: 35
Joined: Mon Jul 22, 2013 8:36 am

Re: turn off one pi from another?

Thu Aug 08, 2013 7:55 pm

can you send an ssh command from openelec? also I said before I don't want to use a PC with putty to turn it off.

W. H. Heydt
Posts: 14414
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: turn off one pi from another?

Thu Aug 08, 2013 8:43 pm

ViolentMonk wrote:can you send an ssh command from openelec? also I said before I don't want to use a PC with putty to turn it off.
PuTTY certain runs on Raspbian (I've never used openELEC so I couldn't say if there is a version there), but you need to bring up the GUI to do so. PuTTY is useful for having one or more available configs with different settings, or for people who have issues with command line (not just "afraid of", but also "which options do I need this time?").

ViolentMonk
Posts: 35
Joined: Mon Jul 22, 2013 8:36 am

Re: turn off one pi from another?

Thu Aug 08, 2013 9:44 pm

I was wanting the ssh to come from openelec not raspbian because the other pi is headless. I have an IR remote/receiver for my openelec pi to turn it off. would it be best just to get another receiver for the headless or is there a way to ssh from openelec?

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: turn off one pi from another?

Fri Aug 09, 2013 7:28 am

Check the OpenELEC forum on how to get to the command-line.
I suppose OpenELEC is the wrong distro , it doesn't have
package managment and X. I guess a commandline SSH client
might still be included.


AFAIK on RaspBMC you can install anything you could on
Raspbian , including a desktop and then PuTTY.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

dspolleke
Posts: 114
Joined: Thu Feb 07, 2013 7:09 pm
Location: Netherlands

Re: turn off one pi from another?

Fri Aug 09, 2013 8:22 am

Sure,

on both raspberry Pi's you issue (as root)
ssh-keygen

and create a keypair WITHOUT a passphrase(just enter)

Code: Select all

openelec:~ # ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/storage/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /storage/.ssh/id_rsa.
Your public key has been saved in /storage/.ssh/id_rsa.pub.
The key fingerprint is:
03:73:af:9f:6b:d0:f8:8b:d4:b9:b6:b0:5d:3b:5e:24 root@openelec
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|                 |
|      o .        |
|       + .       |
|        So. E .  |
|        o+.. o   |
|        +oo . .  |
|       . *++.o   |
|        ooO=o.   |
+-----------------+
openelec:~ # 
look at the Public part of the key
and paste that into the authorized keys file of the other pi

Code: Select all

openelec:~ # cat .ssh/id_rsa.pub 
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDNrkOU5qu8Isy1gO5ibBu2su6IJoBU/AmVF8wpnLMLxnyf7BzJPPp7wUNJMOFc8o49XZkNnM5JaSJWXGil89GNsb804LdqB0yieGwm9RFSL2xiilEF7i7pcSeS9WHDSk9wIMaB6/L4LZPqcWZtCwt/K0yfOCUHO5Wt7sqDTUfPia6QgjKGqiG5jmLk1Xel592iS4P4Mcc5WUuaRZH9w0BFJTN9aVhA3a0J0Rar/E7kgherteCNRCEyjbSMrV3WysmXZhdp3rFXy924HuO24UPtKC76MAgsz1h/dQyLUASkPOwXSxJVf+jpdi0XdITHxzJO91jOE9V4kfk4qUX2Oe4X root@openelec
vi .ssh/authorized_keyz

if you do so you can login from one pi to the other without being prompted for a password.
The two machines trust each other.

so if you create a script

Code: Select all

#!/bin/bash
host=192.168.2.123 # ip of other pi you want to shutdown
ssh $host "/sbin/halt "
and save it somewhere let see /root/remoteshutdown.sh make it executable (

Code: Select all

chmod +x  /root/remoteshutdown.sh
)
For the next step create a shortcut or a command... I googled a bit..

WARNING UNTESTED
take a look at
http://forum.xbmc.org/showthread.php?tid=140782
Please read: http://www.biblegateway.com/passage/?search=Matthew+7%3A7&version=NIV

Use loads of sunscreen, use the search, be elaborate in questions, paste commands and error messages, and remember google is your friend!

ViolentMonk
Posts: 35
Joined: Mon Jul 22, 2013 8:36 am

Re: turn off one pi from another?

Sat Aug 10, 2013 1:08 am

woo thank you! I think that's what I need I'll try it out and post if I mess it up or need more help. :D

ViolentMonk
Posts: 35
Joined: Mon Jul 22, 2013 8:36 am

Re: turn off one pi from another?

Mon Aug 12, 2013 9:27 am

welp it looks like I'm not very good at this so how do I install putty on raspbmc and start it?

User avatar
RaTTuS
Posts: 10748
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: turn off one pi from another?

Mon Aug 12, 2013 9:29 am

ViolentMonk wrote:welp it looks like I'm not very good at this so how do I install putty on raspbmc and start it?
you don't need putty on raspbmc
just the sshd
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: turn off one pi from another?

Mon Aug 12, 2013 9:35 am

Check the RaspBMC forums/ homepage /Wiki on how
to get to the commandline.


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

Thaddy
Posts: 174
Joined: Wed Mar 06, 2013 11:28 am

Re: turn off one pi from another?

Mon Aug 12, 2013 9:51 am

Actually, I am missing something in these replies :mrgreen:

SSH into the second pi and then issuing ¨sudo halt" doesn't actually power off the Pi.
For that you also have to build a little hardware project with your pi that disconnects the power supply :)
There are many examples on how to do this on this forum:
For example: use a little relay circuit on the first pi to switch off the mains for the second Pi

Or even simpler and possibly cheaper: build a simple circuitbreaker that interrupts the 5 volt line for the second pi. This can easily be controlled from the first pi via GPIO.
Haven't seen a schematic for that yet, though it is VERY simple and probably costs you only a couple of wires and a resistor.

ViolentMonk
Posts: 35
Joined: Mon Jul 22, 2013 8:36 am

Re: turn off one pi from another?

Mon Aug 12, 2013 10:00 am

it says you get into commandline by hitting exit on xbmc then hit ESC on your keyboard...anyone know if i have to use a keyboard? i have a rc6 remote can I use that? I really don't have an extra keyboard..also I know it doesnt "power it off". I switch off the power using a surge protector and a wall light switch. I just want to be able to "safely" turn them off with sudo halt from the first pi then shut off the power when I leave the room.

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: turn off one pi from another?

Mon Aug 12, 2013 10:04 am

Well , you could SSH into your Pi ...

Use PuTTY on Windows . Or MobaXTerm.

ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

ViolentMonk
Posts: 35
Joined: Mon Jul 22, 2013 8:36 am

Re: turn off one pi from another?

Mon Aug 12, 2013 8:04 pm

I don't mean to be rude ghans but did you read the title of the thread or any of my other posts? I need one raspberry to be turned off from a second raspberry connected to a tv screen while the other is headless without sshing from a PC other than to install or set up software/settings.

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: turn off one pi from another?

Tue Aug 13, 2013 7:38 am

And thats what i'm suggesting. Using SSH to setup
dspollekes SSH-based solution. After that ,
you shouldn't need to SSH again from your PC.
I guess both Pis and your Laptop/Desktop are connected
to the same LAN ?


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

ViolentMonk
Posts: 35
Joined: Mon Jul 22, 2013 8:36 am

Re: turn off one pi from another?

Tue Aug 13, 2013 10:22 am

I create the authorized keys I just cant figure out how to "paste them" into each other's authorized keys file. :/ it keeps saying E492: Not an editor command: how do I actually add the keys?

User avatar
RaTTuS
Posts: 10748
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: turn off one pi from another?

Tue Aug 13, 2013 10:25 am

ssh-copy-id user@remotesystem
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

ghans
Posts: 7883
Joined: Mon Dec 12, 2011 8:30 pm
Location: Germany

Re: turn off one pi from another?

Wed Aug 14, 2013 12:20 pm

Was it really necessary to recommend vi to someone
who does not know how to use it ?


ghans
• Don't like the board ? Missing features ? Change to the prosilver theme ! You can find it in your settings.
• Don't like to search the forum BEFORE posting 'cos it's useless ? Try googling : yoursearchtermshere site:raspberrypi.org

ViolentMonk
Posts: 35
Joined: Mon Jul 22, 2013 8:36 am

Re: turn off one pi from another?

Fri Sep 20, 2013 11:15 pm

when I try to ssh the key from one to the other is says there is no such file or directory. :(

EDIT: I put in sudo scp /home/pi/keypair3.pub pi@192.168.0.188:keys(.170 for the second)
it looks like I got one to cooperate and accept the keypair thing but the other says access is denied. :,(

User avatar
RaTTuS
Posts: 10748
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: turn off one pi from another?

Sat Sep 21, 2013 8:06 am

http://www.raspberrypi.org/phpBB3/viewt ... 44#p404121
is how you move keys to a remote system
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

Return to “Beginners”