Shutting Down Multiple Raspberry Pi Linux Systems: Network SSH Access Control
In this article, we will discuss how to control SSH access to multiple Raspberry Pi Linux systems within a local network (50.100.x.x with IP addresses ranging from 50.100 to 50.106). The goal is to shut down the Raspberry Pi systems remotely via SSH without having to physically access each device.
Prerequisites
- Multiple Raspberry Pi systems with Raspbian OS installed
- SSH enabled on all Raspberry Pi systems
- Local network with IP addresses ranging from 50.100 to 50.106
Setting Up SSH Access Control
To control SSH access to multiple Raspberry Pi systems, we need to set up a centralized management system. One way to achieve this is by using a configuration management tool such as Ansible. In this example, we will demonstrate how to use Ansible to manage multiple Raspberry Pi systems and control SSH access.
Step 1: Installing Ansible
To install Ansible, run the following command on your local system:
sudo apt-get install ansible
Step 2: Configuring Ansible Inventory
Create a new inventory file called rpi in the /etc/ansible/hosts directory:
sudo nano /etc/ansible/hosts
Add the following lines to the inventory file:
[rpi]
50.100.x.x
50.101.x.x
50.102.x.x
50.103.x.x
50.104.x.x
50.105.x.x
50.106.x.x
Step 3: Creating Ansible Playbook
Create a new playbook file called shutdown.yml in a new directory called ansible:
mkdir ansible
nano ansible/shutdown.yml
Add the following lines to the playbook file:
---
- hosts: rpi
become: yes
tasks:
- name: Shutdown Raspberry Pi system
command: shutdown -h now
async: 0
poll: 0
ignore_errors: yesStep 4: Running Ansible Playbook
Run the following command to execute the playbook:
ansible-playbook -i rpi shutdown.yml
In this article, we have discussed how to control SSH access to multiple Raspberry Pi Linux systems within a local network. We have demonstrated how to use Ansible to manage multiple Raspberry Pi systems and control SSH access. By following the steps outlined in this article, you can shut down multiple Raspberry Pi systems remotely via SSH without having to physically access each device.
References
- Ansible documentation: https://docs.ansible.com/ansible/latest/index.html
- Raspberry Pi documentation: https://www.raspberrypi.org/documentation/
- SSH documentation: https://www.openssh.com/