What is SSH?
Secure Shell (SSH) is a protocol and command interface for secure access to a remote computer. It is widely used by network administrators to remotely manage web servers and other types of servers. Data and commands transferred using SSH are encrypted and protected in several ways. Both ends of the client/server connection are authenticated with a digital certificate, and the passwords are encrypted. To make a request to the server via Secure Shell, the SSH daemon (or server application, service) should be installed and running there.
SSH on Windows
By default, SSH is available on UNIX-like operating systems. However, you can also connect to a Windows server via SSH. There are several popular SSH servers for Windows. An example is Cygwin, which is installed as a service on the system. From a variety of SSH clients for Windows, it is worth mentioning PuTTY. It differs from its counterparts in a friendly interface and a rich set of features, including the ability to set up proxy servers and save connection settings. Starting with Windows 10 (version 1809 and later) or Windows Server 2019, a built-in OpenSSH client is available on the system, which can be used to connect to remote devices. You can install it in the Applications & Features section:
- Settings -> Applications -> Optional features -> Add a feature.
- Find OpenSSH Client in the list and click Install.
To connect to a remote host via SSH, run a PowerShell command line or cmd.exe. Enter the command:
ssh username@host
For example, to connect to a Linux host with IP address 192.168.1.100 as root, run the command:
ssh root@192.168.1.100
The first time you connect, you will be prompted to add the host key to trusted: type yes and press Enter. After that, you will be prompted for the password of the specified account. Enter the root password and press Enter. The console of the remote Linux host will open, in which you can already fully work and execute commands.
Monitoring Host Parameters via SSH
With SSH, you can monitor many parameters of a remote host under Linux, Android, or other *nix-like system. SSH provides remote control of the operating system, including running various scripts and getting information. Using a remote connection via SSH, the monitoring program can execute arbitrary scripts and OS commands, receiving and processing the result of their work.
Let's show how the SSH monitoring is configured in 10-Strike Network Monitor (Pro).
After the program installation, you can scan the network and add found hosts to the monitoring list, or you can create them manually. Add a Linux host to the list (Hosts -> Add host):
By default, an ICMP ping check is created for each new host, allowing you to monitor its availability over the network. Let's create the second check for monitoring SSH (Checks -> Add check):
The program already has several templates to help you with the check configuration:
- free/used RAM monitoring
- monitoring of average CPU load per minute, for 5 and 15 minutes (CPU Load)
- monitoring free space on specified disks
To monitor other parameters, it is possible to use custom commands and bash scripts that will be executed on a remote computer and return parameters to the program via SSH. For example, using the command
cat /proc/15410/status |grep -i VMSIZE | awk '{print "result=",$2}'
you can get the amount of memory occupied by the process with PID 15410. By clicking the Get button, you can check the operation of the script or command. In case of the successful request execution, the field next to it will be filled with the result.
The response of a script or command should begin with the line
result=
Use the syntax for this:
| awk '{print "result=",$1}'
$1 is the number of the returned parameter in the response.
In the example:
/bin/date "+%F %T" | awk '{print "result=",$1}'
$1 returns the date, $2 returns the time.
If the parameter is numeric, then the command or script must return only the parameter itself, without accompanying lines and comments. In addition to numeric parameters, the program can parse lines and search them for the given text. Set the threshold value of the parameter at which the test will be considered passed.
After checking the operation of the script or command, you can proceed to the next step of the Monioring Settings Wizard. Here, in the Display on Charts section, you can convert the value received by the script or command to the desired measure units. In our case, we convert kilobytes to megabytes by dividing by 1024. We can also confiure the indicator type here.
At the last step, you can set the alert parameters in case the parameter value goes beyond the condition. For example, let's enable sending a message to Slack.
Click Finish.
Okay. The check has been created and is already running. Its result is visible in the list of checks (see the free disk space example below).
You can also display the chart of the monitored parameter (see the average CPU load example below):
With this check, you can monitor any Android device, as long as you can install an SSH server on it. For example, the program successfully monitors smartphones of popular brands via Wi-Fi after installing any SSH server from Google Play.
Requirements: Windows XP/Vista/7/8.1/10/11, Server 2003/2008/2012/2016/2019/2022 supported.