blog.mirabellette.eu

A blog about digital independence and autonomy

Tips

Check if it is possible to establish a SSH connection with Bash

Written by Mirabellette / 20 march 2018 / no comments

Hello everyone

I am continuing to write an article each month. I add some little title and subtitle to improve the ease of reading. Today, I want to share to you a little trick I use to check if it is possible to establish a SSH connection with a remote host.

Introduction

Use case

  • You want to transfer some files with SSH protocol. You want to be sure it is possible to establish a connection and be notified if it is not possible.
  • You want to check periodically if it is possible to connect to a remote host with SSH.

What I do

I created a bash script to open a connection with the remote host in SSH and check if it works well. If it doesn't, I send an email to a specific address.

The main part

Scripts

Both scripts are available in Github following MIT LICENCE. You can find them here.

Script to check ssh connection

script

Crontab

crontab

Requirement and advice

  • You need to have a bash prompt after you connected to ssh.
  • You need to have a mail transfer agent properly configured.
  • You need to check when you established a SSH connection that you don't receive any warning message from SSH. In this case, the status variable will got another value than "ok" and the script will considered you aren't be able to establish a connection.

Sources

Conclusion

I know that it must be a better way to test that but it fit well for my use cases.

Social media

If you find this article interesting, feel free to subscribe to my RSS flux and to follow me on Mastodon. Don't hesitate to share it if you think he could interest someone else.

Classified in : Tips / Tags : none

Ubuntu 17.10 - tools and configuration

Written by Mirabellette / 01 january 2018 / no comments

I bought a new computer last year and I had to choice to install a new operating system. I am waiting for Qubeos 4.1 (x.0 are most of the time fucked up).
I choice to use Ubuntu 17.10 because packages are quite new and it is easy to use. To get an operative system fully usable, I had to do configure it and do some trick to get it as I want.

You can find below some tools I installed and some configuration I did.

First of all, the first thing you had to know is Ubuntu 17.10 has Gnome installed. Unity was give up by Ubuntu Inc. Astonishingly, even if it is the first release with Gnome, it works pretty well.

Display full date to toolbar

I wanted to display the full date to my toolbar.

sudo apt-get install gnome-tweak-tool

Launch tweaks
Top Bar > clock > Date > Calendar > Show week numbers

An ebook reader

There is no ebook reader by default in Ubuntu 17.10. Calibre is the most famous of them.

sudo apt update && sudo apt install calibre

Network manager

Network manager is installed on Ubuntu 17.10. I don't really like it because it changes your configuration. I try to disable these modifications in order to have a better control.
Randomize your MAC network address
Ubuntu allows by design to generate a random network MAC address at each network connection. It is a basic privacy settings which could help you to prevent mac address ban or to increase the difficulty to track your habits.

vim /etc/NetworkManager/conf.d/30-mac-randomization.conf
[device-mac-randomization]
# "yes" is already the default for scanning wifi.scan-rand-mac-address=yes

[connection-mac-randomization]
ethernet.cloned-mac-address=random
wifi.cloned-mac-address=random

To be sure if works well,

ifconfig && service network-manager restart && sleep 5 && ifconfig

The mac addresses from your ethernet interface and wifi interface must be different from the first ifconfig result displayed.
sources:

Disable automatic update of /etc/resolv.conf
When you want to use a specific dns, you have to modify /etc/resolv.conf. NetworkManager modifies this file each time it started. To avoid that:

vim /etc/NetworkManager/NetworkManager.conf
[main]
dns=none

service network-manager restart

To be sure if works well,
cat /etc/resolv.conf
The previous /etc/resolv.conf must be displayed.
sources:

Disable the DNS resolver
Ubuntu comes with his own resolver integrated in Systemd, I don't need it.

systemctl disable systemd-dns
systemctl stop systemd-dns

Speed test in command line

Sometimes it could be useful to measure your bandwidth in CLI.

sudo apt install speedtest-cli
speedtest-cli

Show display picture from others components (usb key, sd cards)

By default, Nautilus shows miniature only from local computer. It could be unconvenient when you have a usb driver which contains pictures. To enable this feature for all devices:
open nautilus (files) > preferences > search & preview > thumbmails > all files

Show information system

If you want to find some information about your own system configuration.

System Settings > Details > about

Social media

If you find this article interesting, feel free to subscribe to my RSS flux and to follow me on Mastodon. Don't hesitate to share it if you think he could interest someone else.

Classified in : Tips / Tags : none

Dominate yours pdfs with pdftk

Written by Mirabellette / 21 october 2017 / no comments

Hello everyone,

Introduction

I recently have to do a lot of administration stuff. To do that, I often need to manipulate pdf documents, merge them or extract some parts. I wanted to share an extraordinary tool that I recently discover last week : pdtfk

Installation

System where the soft is installed : linux desktop 4.9.0-4-amd64 - x86_64 GNU/Linux
apt-get install pdftk

Usage

It is very easy to understand how it works and how to use it. You can find below two commands really useful that I used.

The first one is used to merge pdf
pdftk file1.pdf file2.pdf cat output file-result.pdf

The second one is used to extract some page from a document. In the example below, I ask to extract only the page 2 and 3.
pdftk big_file.pdf cat 2-3 output file_with_page_2_and_3.pdf

Of course, this tool can do a lot of other things with your pdf. Do not hesitate to read the documentation at https://www.pdflabs.com/docs/pdftk-cli-examples/.You can also find some examples here too.

Have a good day,
Mirabellette

sources

Social media

If you find this article interesting, feel free to subscribe to my RSS flux and to follow me on Mastodon. Don't hesitate to share it if you think he could interest someone else.

Classified in : Tips / Tags : none