au Qua Station - Part 7 - Configuring utilities for a headless server

Basically, I am using these machines for file syncing, so I don't need to access them directly very often, but sometimes I might need to check the status, delete files, update the system, etc.  I can do this via SSH (or, preferably, MOSH), but typing passwords over and over every time is a pain - so we shoudl automate this.

The first thing to do is to go to the laptop/desktop you want to use to connect from, and run:

ssh-copy-id user@destination

for each machine you want to be able to log into automatically.

(You may have to generate an SSH key first if you haven't already by running ssh-keygen).

with the login automated.  

Enter dsh

Distributed Shell is a tool that allows you to run the same SSH command on multiple machines at once, instead of logging into each machine separately to issue the command. 

In Ubuntu, installation is straightforward:

sudo apt-get install dsh

Next, edit the config file which defines the hosts that dsh knows about:

sudo nano /etc/dsh/machines.list  


Once this is SSH keys are set up to allow for automatic login, and the hosts are defined in the configuration file, then we are ready to go:

As an example, let's check the free space on the home partition of all of our machines.

console@quastation1:~$ dsh -aM -c df -h | grep home

localhost: /dev/sda2       917G  219G  698G  24% /home

quastation5.local: /dev/sda2       917G  342G  575G  38% /home

quastation6.local: /dev/sda2       917G  155G  762G  17% /home

quastation4.local: /dev/sda2       916G  476G  439G  53% /home

quastation2.local: /dev/sda2       917G  330G  587G  36% /home

quastation3.local: /dev/sda3       868G  122G  745G  15% /home

quastation7.local: /dev/satab3     853G  686G  166G  81% /home

quastation8.local: /dev/sataa2     867G  452G  413G  53% /home

As you can see, dsh will run your command on each machine and return the results together.  

For quick commands like df, etc., dsh is great.  


if you are interested in a GUI solution for Unix, then clusterssh might be more your speed.  A great alternative for Windows is Mobaxterm.  


But sometimes a web interface is better - luckily, there is a nifty lightweight utility for general maintenance and reporting called "cockpit".  

sudo apt-get -y install cockpit cockpit-machines

sudo systemctl start cockpit

You only need run the commands above and then visit http://your-machines-hostname:9090/

The server uses SSL, so you will probably have to select to ignore the self-signed certificate in your browser.  

With this utility, you can view all sorts of data about your server(s):


Depending on the version you install, the display may be slightly different (the functionality is mostly the same):



You can also get a command prompt from this page:

The emulation is much better than I expected.

Best of all, though, instead of logging into each server, you can link them so that you log into one machine and it will show you the statistics of the other machines overlaid on the same graph.  

For example, you can monitor real time network traffic:


Or Disk I/O:

CPU could be interesting too...


Another nice bonus is that this tool uses the real system logins so there isn't another password to remember.  

FileBrowser

While Cockpit is great for reporting, what if I need to perform file operations?  
I can log in via mosh and use mc or such, but if only there was a nice web based interface... well, there is.  I looked for the simplest most lightweight thing I could find that oculd hanvle upload/download/deletion/moves/copies, and came across "file browser".  While the name is less than creative, it works great.  

Installation is odd, but easy:

curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bashDownloading File Browser for linux/arm64...

https://github.com/filebrowser/filebrowser/releases/download/v2.15.0/linux-arm64-filebrowser.tar.gz

Extracting...

Putting filemanager in /usr/local/bin (may require password)

Successfully installed


Update:   The installation has changed, it should now be:

curl -fsSL https://raw.githubusercontent.com/filebrowser/get/master/get.sh | bash

filebrowser -r /path/to/your/files


It can be run with:

nohup filebrowser -a 0.0.0.0 -r/home/share/ &



This basic interface allows:
* Deletion
* Viewing/editing (text files)
* Uploading
* Downloading
* Rename / Move
* Copy
and some other things, the most notable of which is 
* Sharing
This obviously only works if your device is accessible to the internet, but if you want to share a large file, you can use this feature.


Once you select "Share", it will create a link something like:
http://quastation1.local:8080/share/Sd5WGiDH

Upon accessing the link, a page like the following will appear:

The QR code is a nice touch.  

This isn't as full featured as something like Synology DSM, but it it is not bad for what it is - it allows you to see inside that headless box and do quick file management via the web.  

Besides that, it can view text files and PDF files online without downloading them.  

There is a terminal feature as well, but it is not as full featured as that of cockpit.  

Gripes about file browser:
It's hard to argue with free, but there are a few rough edges:
1. The installation is non-standard, and then it won't start automatically unless you hack your startup files on your own.  (i.e. edit /etc/rc.local).
2. The authentication is also not standard, and so there are special users just for this software which you have to remember.  


Continue to QuaStation Part 8 - Setitng up ResilioSync 

Comments

Popular Posts