17 Apr
Hi readers,
Today I am going to share a detailed guide on how remotely deployed raspberry pi hardware( or any hardware running docker ) can be managed. Shellhub is an excellent software stack that can be used for this purpose. Through this we can ssh into the devices remotely where ever the device is in the world, as far we have a working internet connection. Another advantage is that we don't have to provide Static IP/ Port forwarding in routers, use dynamic DNS services to reach our endpoint. Also, it should be noted that the remote login middleware can be deployed in our own server, and add more security through https access, etc.
Instructions for using Shellhub for remote device login and management.
Install docker in Server (Following steps tested in Ubuntu server 18.04)
```
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
sudo apt install docker docker.io
```
Run shellhub server
```
git clone -b v0.2.1 https://github.com/shellhub-io/shellhub.git shellhub-v0.2.1
cd shellhub-v0.2.1
./bin/keygen
sudo docker-compose up -d
```
Create shellhub admin login
```
sudo ./bin/add-user <username> <password>
```
Open the Shellhub server and manage devices from there
To do this find the IP address of the server. Assuming it is ip address of the server or domain like myshelhubserver.com (If a domain is linked you can use that)
-
-- Open browser and in the address bar type your server IP or domain name - http://192.168.1.201 or http://myshelhubserver.com
-
-- Login using the username and password created in the previous step using the command "sudo ./bin/add-user ..."
-
-- Click on add device and copy the command shown. This command needs to be supplied on the raspberry pi terminal later.
Steps in RPI
In raspberry pi, the essential requirement is to have docker installed.
```
sudo apt install docker-compose
```
Install shellhub agent.
Paste the command line script obtained from the Shellhub server into the RPI terminal window.
If there is a permission error, then try replacing "sh" with "sudo sh" in the copied command.
After successful installation, the new device should be appearing in the ShellHub panel. Check the Online devices section to see your device online
Login into the device
- Find the device in the Device List.
- Click on the terminal icon.
- Enter the RPI username and password to get the ssh access.
- Now you can run any programs, update running programs etc.
Important Links
- Source Code: https://github.com/shellhub-io/shellhub
- Trouble Shooting Guide: http://docs.shellhub.io/troubleshooting/
In the next tutorial, I will talk about using Remote Desktop with the help of Shellhub.