12 063
правки
(Новая страница: «Startup of the OpenVPN service on the controller is enabled by the command: <pre>update-rc.d openvpn defaults</pre> Check server availability <code>ping 10.8.0…») |
|||
(не показаны 22 промежуточные версии этого же участника) | |||
Строка 293: | Строка 293: | ||
== AutoSSH == | == AutoSSH == | ||
Another fallback controller connection will be based on the <code>AutoSSH</code>. The mechanism of work is as follows: SSH-connection from the controller to the server is established, and the ssh-port of the controller is forwarded to one of the free ports on the localhost server. Service аutossh ensures that the ssh connection is not broken, and in case of the gap restores it. Recovery is not instantaneous — for a while, the port used on the server's <code>localhost</code> is held by the <code>sshd</code>daemon. | |||
Install on the controller <code>apt-get install autossh</code>. Generate a key pair for the user <code>root</code>: | |||
<pre>ssh-keygen </pre> | <pre>ssh-keygen </pre> | ||
Password is empty. | |||
To maintain remote connections, create a user <code>remote</code> on the server with the shell <code>/bin/false</code>: | |||
< | <заранее>команду adduser --Home /для дома/дистанционный --оболочку /bin/false в удаленных и </pre> | ||
Here, in file <code>/home/remote/.ssh/authorized_keys</code> on the server, we add key created on the controller <code>/root/.ssh/id_rsa.pub</code> with the preamble | |||
<code>no-agent-forwarding,no-X11-forwarding,permitopen="localhost:62001" </code> | <code>no-agent-forwarding,no-X11-forwarding,permitopen="localhost:62001" </code> | ||
this will provide additional security for the server when the controller is connected. Port 62001 is the port of the localhost server to which the ssh port of this controller will be redirected. | |||
The first time we connect from the controller to the server manually: | |||
<pre>ssh remote@vpn.mydomain.com </pre> | <pre>ssh remote@vpn.mydomain.com </pre> | ||
On the controller, create a file <code>\etc\systemd\system\autossh.service</code> to run it <code>autossh</code> as a service: | |||
Строка 335: | Строка 335: | ||
WantedBy=multi-user.target | WantedBy=multi-user.target | ||
</pre> | </pre> | ||
Add service to autorun on the controller | |||
<pre>systemctl enable autossh.service</pre> | <pre>systemctl enable autossh.service</pre> | ||
After starting the service, we can connect to the controller on the server using the command | |||
<pre>ssh 127.0.0.1 -p 62001</pre> | <pre>ssh 127.0.0.1 -p 62001</pre> | ||
== | == Data transfer from controller to the cloud == | ||
To send MQTT messages from the controller to the cloud service, the MQTT bridge is used, the configuration of which is configured on the controller in the file <code>\mnt\data\etc\mosquito\conf.d\bridge.conf</code> | |||
<pre> | <pre> | ||
connection wb_devices_cloud.wb_A7ZO7UCC | connection wb_devices_cloud.wb_A7ZO7UCC | ||
Строка 359: | Строка 359: | ||
</pre> | </pre> | ||
Then run the command | |||
<pre> | <pre> | ||
Строка 366: | Строка 366: | ||
If you want to transfer data to multiple servers at the same time, create multiple <code>connection</code>partitions. | |||
== | == Possible GPRS connection problems == | ||
There can be several possible reasons for the lack of GPRS connection. | |||
* | * The paid traffic limit has ended. | ||
* | * Low voltage, poor contact to the antenna. | ||
* | * SIM cards of some operators are designed only for 4G-network, 3G-connection to install them will not work. | ||
* | * Check if the SIM card is inserted correctly into the slot. | ||
* | * The SIM card may not be working. | ||
* | * Your data plan does not include packet data. | ||
Before you go to your personal account and call the provider, you can perform a number of simple checks. | |||
Run the command | |||
<pre>gammu networkinfo</pre> | <pre>gammu networkinfo</pre> | ||
Строка 396: | Строка 396: | ||
</pre> | </pre> | ||
It is important that the controller is connected to the packet data network <pre>(GPRS : attached)</pre> and GPRS connection is established. | |||
Then evaluate the signal strength in minicom with <code>AT+CSQ</code> | |||
You will get the result as <code>13.99</code> | |||
The first digit shows the signal strength: > 9 — satisfactory, > 14 — good, > 19 — excellent. Low and unstable CSQ values mean that the antenna is poorly positioned, carelessly connected, radio placement is unfavorable. | |||
If both checks are passed, but there is no connection, contact your provider (check in your personal account), you can check the SIM card in your smartphone. |
правки