lazarus78
Posts: 236
Joined: Thu Jul 25, 2013 5:16 pm

Send remote command with SSH

Wed Apr 30, 2014 6:55 pm

I have several Pis around displaying reports, which are really just php files and a web browser. They are on a 5 minute refreshing loop I set up with a script, and all works fine and dandy, but sometimes I may need to manually refresh them. I set up an alias using the "xdotool" to basically hit the F5 key, but with currently 3 displays, and ~7 more in the future, I don't want to have to do this to each one at a time. So I was looking in to doing it with SSH's ability to submit remote commands without fully logging in.

My idea was to create a small script that will systematically go through each Pi and submit my refresh command automatically, but the exact way to do this alludes me. Most pages around the net are written in technical jargon that just confuses me, so laymans terms are appreciated.

What I've tried:

Code: Select all

 ssh [email protected] 'cat ~/MyFile.txt'
This works, but it prompts for the login password, understandably, but is there a way to bypass this, to automatically input the password? My goal is as little user input as necessary.

User avatar
joan
Posts: 14473
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Send remote command with SSH

Wed Apr 30, 2014 7:07 pm

I'm not sure if this is the clearest example, it was just the first on Google.

http://www.linuxproblem.org/art_9.html

You need to set up some keys.

lazarus78
Posts: 236
Joined: Thu Jul 25, 2013 5:16 pm

Re: Send remote command with SSH

Wed Apr 30, 2014 8:02 pm

Ah, so in short, i need to put Computer A's public key on the Pi's I want to include in my script? Simple enough. Thanks for the site.

User avatar
DougieLawson
Posts: 36578
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Send remote command with SSH

Thu May 01, 2014 12:08 pm

lazarus78 wrote:What I've tried:

Code: Select all

 ssh [email protected] 'cat ~/MyFile.txt'
This works, but it prompts for the login password, understandably, but is there a way to bypass this, to automatically input the password? My goal is as little user input as necessary.
If you set up a private key on the client and store the public key in /home/MyUser/.ssh/authorized_keys on 10.2.3.100 you can log in securely without needing any password.
https://www.debian.org/devel/passwordlessssh has the complete recipe.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

Return to “Beginners”