Joram
Posts: 3
Joined: Mon Oct 15, 2018 9:19 am

PI management software via SSH

Mon Oct 15, 2018 9:38 am

I have several Raspberry PI's around and manage them via SSH. I've made some scripts to execute a command via SSH. I'm wondering if there is some software to do that better for me WITHOUT installing any client software. I'm looking for a SSH only solution. I would like to execute commands on the PI's like update, get information like cpu usage etc.

B.Goode
Posts: 6540
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: PI management software via SSH

Mon Oct 15, 2018 11:54 am

What Operating System is running on the client machines that you don't want to install additional software on?

For example, recent and updated versions of Microsoft Windows 10 would not need additional software.

mfa298
Posts: 1322
Joined: Tue Apr 22, 2014 11:18 am

Re: PI management software via SSH

Mon Oct 15, 2018 12:45 pm

Joram wrote:
Mon Oct 15, 2018 9:38 am
I have several Raspberry PI's around and manage them via SSH. I've made some scripts to execute a command via SSH. I'm wondering if there is some software to do that better for me WITHOUT installing any client software. I'm looking for a SSH only solution. I would like to execute commands on the PI's like update, get information like cpu usage etc.
There are a range of configuration management tools that can be used on the Pi (Ansible, Chef, Puppet, Salt being the more common ones) although most of those need a package installing on the clients and possibly a server.

Ansible might be worth looking at as I think it only needs ssh on the client devices. Personally I use chef but that requires a large package installing on the clients (and last time I tried didn't work on the Pi1/Zero).

tpyo kingg
Posts: 317
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: PI management software via SSH

Mon Oct 15, 2018 2:03 pm

More details would help but one of the things you can do automate things on the RPis would be to prepend command="..." to the public keys to make each use of the key trigger a specific script. See "man sshd" in the section "AUTHORIZED_KEYS FILE FORMAT" for more information. You can have multiple keys per RPi if needed, each one triggering a different action. That doesn't scale so well but works very nicely with a smaller number of target machines. For larger numbers of machines, you might consider ansible.

Shortcuts can be put in the ~/.ssh/config file on the client you are connecting from to facilitate that. Or else the private keys themselves can be wrapped in a shell script and be made executable.

mfa298
Posts: 1322
Joined: Tue Apr 22, 2014 11:18 am

Re: PI management software via SSH

Mon Oct 15, 2018 2:28 pm

tpyo kingg wrote:
Mon Oct 15, 2018 2:03 pm
More details would help but one of the things you can do automate things on the RPis would be to prepend command="..." to the public keys to make each use of the key trigger a specific script. See "man sshd" in the section "AUTHORIZED_KEYS FILE FORMAT" for more information. You can have multiple keys per RPi if needed, each one triggering a different action.
You can also put commands on the ssh command line (no need for managing lots of keys and other files)

Code: Select all

[[email protected] ~]$ ssh [email protected] cat /proc/cpuinfo
[email protected]'s password: 
processor	: 0
model name	: ARMv6-compatible processor rev 7 (v6l)
BogoMIPS	: 997.08
Features	: half thumb fastmult vfp edsp java tls 
CPU implementer	: 0x41
CPU architecture: 7
CPU variant	: 0x0
CPU part	: 0xb76
CPU revision	: 7

Hardware	: BCM2835
Revision	: 9000c1
Serial		: 000000001211e5cb
which can also lead to some funky stuff

Code: Select all

[[email protected] ~]$ ssh [email protected] "sudo tar -C /home -czf - mfa298" | ssh [email protected] "sudo tar -C /home -xzf - "
Should ssh into pi1 and tar up /home/mfa298 and pipe the data stream to pi2 and untar it in /home, so copying my home directory from one Pi to another. This sort of command is useful if the two Pi's can't communicate directly between each other (but there's another host that can talk to both)

jahboater
Posts: 3032
Joined: Wed Feb 04, 2015 6:38 pm

Re: PI management software via SSH

Mon Oct 15, 2018 2:52 pm

mfa298 wrote:
Mon Oct 15, 2018 2:28 pm
You can also put commands on the ssh command line (no need for managing lots of keys and other files)

Code: Select all

[[email protected] ~]$ ssh [email protected] cat /proc/cpuinfo
[email protected]'s password: 
processor	: 0
model name	: ARMv6-compatible processor rev 7 (v6l)
Make sure to setup public/private key authentication to avoid the password requests:-

ssh-keygen -t rsa
ssh-copy-id [email protected]
ssh-copy-id [email protected]

Then automated scripts to manage all the pi's are easy because it never stops to ask for a password.

Joram
Posts: 3
Joined: Mon Oct 15, 2018 9:19 am

Re: PI management software via SSH

Tue Oct 16, 2018 7:17 am

I'm sorry to leave out some details. I don't want to install software on the Raspberry PI's but I don't mind to use software on the 'server' side. Can also be a linux/raspberry pi. I already have the ssh key's installed but just looking for something to easily manage a list of clients and then when i want to execute a command the script does it for every client and nicely shows the output.
I imagine something like a script of simple web application with sqlite db for commands and client list. I know salt but that is to much for my purpose, I also have some PI's of a client where i'm not allowed to install software on. I just want occasionally trigger the software update command, check CPU temperature, disk space and this kind of things.

If it doesn't exists I will make some scripts with the ssh command like mfa298 posted but I had the idea that something must already exist like this.

mfa298
Posts: 1322
Joined: Tue Apr 22, 2014 11:18 am

Re: PI management software via SSH

Tue Oct 16, 2018 11:09 am

Joram wrote:
Tue Oct 16, 2018 7:17 am
I imagine something like a script of simple web application with sqlite db for commands and client list. I know salt but that is to much for my purpose, I also have some PI's of a client where i'm not allowed to install software on. I just want occasionally trigger the software update command, check CPU temperature, disk space and this kind of things.
Ansible is quite possibly the thing to look at, the impression I've got is that it just uses SSH to do stuff without needing to install anything on the clients.

Otherwise there are tools (usually based around a terminal application) that lets you send the same command to various open terminals at the same time.

or for really basic automation the bash shell can help: e.g.

Code: Select all

for n in `seq -w 1 20`; do ssh pi${n} vcgencmd measure_temp; done
would ssh into a set of pis named pi01 through pi20 and run vcgencmd measure_temp on each one.

for ongoing monitoring of system state (temperature, disk usage) there are a variety of tools that can do that for you - but they generally require installation of an agent, if this is in an enterprise type environment then it's the sort of thing that's well worth looking at.

Joram
Posts: 3
Joined: Mon Oct 15, 2018 9:19 am

Re: PI management software via SSH

Wed Oct 17, 2018 10:11 am

Ansible looks pretty much what i need. Im going to have a look at it. Thanks!

User avatar
default_user8
Posts: 536
Joined: Mon Nov 18, 2013 3:11 am

Re: PI management software via SSH

Wed Oct 17, 2018 6:00 pm

Two heads are better than one, unless one's a goat head.

Return to “Advanced users”