LinHES Forums
http://forums.linhes.org/

Howto ssh mythtv through sh script
http://forums.linhes.org/viewtopic.php?f=24&t=21131
Page 1 of 1

Author:  dfdario [ Sun Jun 13, 2010 11:50 pm ]
Post subject:  Howto ssh mythtv through sh script

I am used to pass commands from my MBE to any SBE in my network via ssh. This is useful to gather information about the SBEs state before switch them off. I normally did this by an sh script and ssh configured to grant access without password.
Since LinHES does not permit ssh being used without password I had to do it in a differente way.
The solution is sshpass, a tiny program that permits to send the password to ssh even from sh scripts.

Here is the procedure I used to add sshpass to my LinHES MBE and to grant SBE access.

First it needs to assign a password to mythtv account in any SBE in the network (I have 2 SBEs) and a few configuration:
sudo passwd mythtv <type the new password twice)
sudo nano /etc/ssh/sshd_config
and type # before DenyUsers mythtv
#From MBE type:
ssh mythtv@<IP of your SBE> (to do just once for each SBE)
answer with yes whenever requested

Then to compile sshpass from source in this way:
sudo pacman -S make
wget http://downloads.sourceforge.net/sshpas ... .04.tar.gz
tar zxvf sshpass-1.04.tar.gz
cd sshpass-1.04
./configure
make
sudo make install

To check if it works:
/usr/local/bin/sshpass -p 'mythtvpassword' ssh mythtv@<IP of your SBE>

Enjoy

last edited
In my scripts I've also used this way:
sudo /usr/local/bin/sshpass -p '<passwd>' ssh -o StrictHostKeyChecking=no mythtv@<IP_ADDR> "sudo /home/mythtv/bin/ShutdownCheck"

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/