The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,862 other subscribers

Archive for the ‘Linux’ Category

ipmi – Linux: Why does Single User mode work on Serial Console but not on the attached Keyboard/Video/Monitor? – Server Fault

Posted by jpluimers on 2020/05/19

From [WayBack] ipmi – Linux: Why does Single User mode work on Serial Console but not on the attached Keyboard/Video/Monitor? – Server Fault (slightly edited; thanks Patrick!):

Because init has not spawned off multiple TTYs yet (getty, mgetty, etc), so you only have the primary TTY. The primary TTY is the last console= parameter on the kernel command line. All the console parameters get the output, but only the last one will be able to act as input.

–jeroen

Posted in *nix, Debian, Linux, openSuSE, Power User, RedHat, SuSE Linux, Tumbleweed | Leave a Comment »

Show openSUSE:Factory / bootchart – openSUSE Build Service

Posted by jpluimers on 2020/05/15

On my research list: [WayBack] Show openSUSE:Factory / bootchart – openSUSE Build Service.

I bumped here when researching on how to list services: [WayBack] init.d – Command to list services that start on startup? – Ask Ubuntu

It seems few people use it on opensuse, but it is interesting for analysing the boot process nonetheless.

I already found out this is in fact bootchart2: [WayBack] GitHub – xrmx/bootchart: merge of bootchart-collector and pybootchartgui

Some links that should help me further are these:

From the last link, this translation:

A. systemd-analyze

You will see the total computer startup time after:

systemd-analyze

A complete list of how much each individual service has taken is when you complete:

systemd-analyze blame

You will see the most problematic processes after you complete:

systemd-analyze critical-chain

You can create a picture:

systemd-analyze plot> /tmp/systemd-analyze.svg

Suitable for: openSUSE 11.4, 12.x, 13.1, Leap 42.x

Not suitable: openSUSE 13.2

B. bootchart

First, install the bootchart package (bootchart 2 version of the program). If you are using openSUSE Leap 42.x or later, enable bootchart2 (and optional bootchart2-done) service:

systemctl enable bootchart2

systemctl enable bootchart2-done

If you are using openSUSE version 13.1 or earlier, go to YaST → (System) → Startup and enter kernel startup parameters:

initcall_debug printk.time = y quiet init = / sbin / bootchartd rdinitrd = / sbin / bootchartd

The next time you start your computer, the /var/log/bootchart.png image will be created to help you further optimize your system startup. For example, if you do not need an AppArmor who cares about security, you can disable the boot.apparmor service through the YaST Service Configuration Module.

Suitable for: openSUSE 11.4, 12.x, 13.1, 13.2, Leap 42.x

–jeroen

Posted in *nix, *nix-tools, Linux, openSuSE, Power User, SuSE Linux, Tumbleweed | Leave a Comment »

Listing services on OpenSuSE Linux

Posted by jpluimers on 2020/05/15

Nowadays, most OpenSuSE Linux services are systemd based. Listing those is simple with systemctl list-units --all (configured ones) and systemctl list-unit-files (nonconfigured ones as well), though their states can be many as the command-completion for the --state parameter:

# systemctl list-unit-files --state
abandoned deactivating failed masked not-found remounting-sigterm start-pre stop-sigkill waiting
activating deactivating-sigkill final-sigkill merged plugged running stop stop-sigterm
activating-done deactivating-sigterm final-sigterm mounted registered sigkill stop-post stub
activating-sigkill dead inactive mounting reload sigterm stop-pre tentative
activating-sigterm elapsed listening mounting-done reloading start stop-pre-sigkill unmounting
active error loaded mounting-sigkill remounting start-chown stop-pre-sigterm unmounting-sigkill
auto-restart exited making mounting-sigterm remounting-sigkill start-post stop-sigabrt unmounting-sigterm

The odd thing: not all states from the service list are in the completion. These are missing from the list-unit-files:

generated
static
transient

In the past, most services were System V based, where you can use service --status-all. Contrary to the documentation (which indicates “The –status-all option displays the status of all loaded service units.”), it lists all services.

On OpenSuSE though, it now lists both System V based and systemd based services in one go. Since usually there are no more System V services (virtually all have been migrated to systemd a few years ago), the netto result is systemd services.

Based on [WayBack] init.d – Command to list services that start on startup? – Ask Ubuntu

–jeroen

Posted in *nix, *nix-tools, Linux, openSuSE, Power User, SuSE Linux, Tumbleweed | Leave a Comment »

OpenSuSE: keeping an ssh connection alive (convenient for keeping port forwardings up)

Posted by jpluimers on 2020/05/11

Below the steps for ensuring port forwardings are up from an OpenSuSE system to an ssh server using autossh on the client system.

Autossh

Many have written about the benefits of autossh, so I can’t do better than that. A good abbreviated quote is from [WayBack] Autossh for persistent database connectivity – Compose Articles:

Autossh wraps SSH in an application which was designed to monitor the state of the connection. It will also restart SSH if it exits. The idea of the monitoring is that If it sees the packets aren’t going through, it would also restart SSH. …

the developers of OpenSSH added some options – ServerAliveInterval and ServerAliveCountMax – which activate built in connection checking in OpenSSH. Together the options set checking at a set interval and exiting SSH if the count maximum is exceeded. And when SSH exits, autossh will restart it so it serves as much improved replacement as there’s no extra ports needed.

Summary

The scenario is that a client user named autoSshClientUser automatically logs on to a server as user autosshServerUser using autossh from the client system.

The sequence is to first test this manually from the client system using a regular ssh command, then manually with the autossh command from the client system, then automate the starting (and keep alive) of the autossh instance from the client system.

Start configuring the server side first:

  1. Create a user specific for logon (below it is autosshServerUser).
  2. Limit the user to only allow only port forwarding: [WayBacksecurity – How to create a restricted SSH user for port forwarding? – Ask Ubuntu

Then finish confiruging the client side:

  1. Install autossh: zypper install autossh
  2. Ensure autoSshClientUser has an ssh key that does not require a password
  3. Transfer the public key to autosshServerUser on the remote system
  4. Test with an autossh command that suits your situation best
  5. Ensure autoSshClientUser runs a job at or shortly after system boot (after the network is up) that will start autossh with the correct parameters

If the autoSshClientUser is root, then you could use a service to start autossh, but be sure that service depends on a functioning network connection.

If the autoSshClientUser is not root, then usually a user based cron job works best.

Naming idea:

  • Assume the client system is Train and the server is Station
  • The server user could be autosshTrainAtStation
  • The client user could be autosshTrainToStation

Server side

  1. [Archive.is] Installing on other OSes (Debian / Ubuntu;  Debian / Ubuntu; CentOS / Fedora / RHEL; ArchLinux; FreeBSD; OSX)
  2. As root, add he user using [Archive.is]useradd:

    # useradd --create-home --shell /bin/false autosshServerUser

  3. As root use su to become autosshServerUser, then create an ssh key without a password (you need to specify the logon shell) using [WayBackssh-keygen.
    This generates bot a secure rsa and

    # su --shell /bin/bash autosshServerUser
    > cd ~
    > whoami
    autosshServerUser
    > rm -f ~/.ssh/id_rsa ~/.ssh/id_rsa.pub
    > ssh-keygen -t rsa -b 4096 -o -a 100 -f ~/.ssh/id_rsa -N ''
    Generating public/private rsa key pair.
    Your identification has been saved in /home/autosshServerUser/.ssh/id_rsa.
    Your public key has been saved in /home/autosshServerUser/.ssh/id_rsa.pub.
    The key fingerprint is:
    SHA256:... autossh24@linux
    The key's randomart image is:
    +---[RSA 2048]----+
    ...
    +----[SHA256]-----+
    > rm -f ~/.ssh/id_ed25519 ~/.ssh/id_ed25519.pub
    > ssh-keygen -t ed25519 -o -a 100 -f ~/.ssh/id_ed25519 -N ''
    Generating public/private ed25519 key pair.
    Your identification has been saved in /home/autossh24/.ssh/id_ed25519.
    Your public key has been saved in /home/autossh24/.ssh/id_ed25519.pub.
    The key fingerprint is:
    SHA256:... autossh24@linux
    The key's randomart image is:
    +--[ED25519 256]--+
    ...
    +----[SHA256]-----+
    

Client side

I need to check the below links on killing autossh (including the underlying ssh based connection), as you need to use the kill or pkill parameters signals -3 (SIGQUIT), not -9 (SIGKILL) as explained in [WayBack] ssh – How to stop/kill an autossh tunnel? – Super User (thanks mariusmatutiae and dviljoen).

Monitoring the state of the ssh connection needs some parameters (like ClientAliveInterval and ClientAliveCountMax). A good start on that is [WayBack] networking – autossh does not kill ssh when link down – Server Fault.

Setting up a service so root automatically logs on a remote system:

With non-root, it might actually be possible to do this  as a service too given there is a user= parameter in service files:

Though as non-root, most people seem to use cron [WayBack] ssh – Problems with Autossh: running from cron vs terminal – Super User

Please do not use /etc/init.d/after.local as mentioned often (for instance in [WayBack] TUMBLEWEED run a script a boot): this mechanism has been deprecated and won’t work on more recent systems (like 2012 and younger: [WayBack] openSUSE Forums – systemd and using the after.local script in openSUSE 12.1). The same holds for /etc/init.d/boot.local: don’t use, even though many people indicate it works, for instance [WayBack] Run a command at boot.

An interesting approach is at [WayBack] Autossh Startup Script for Multiple Tunnels | Surnia Ulula, though I will stick with what’s below.

Read:

Downloads:

References

Most of the above comes from these links:

–jeroen

Continuation of:

Read the rest of this entry »

Posted in *nix, Communications Development, Development, Internet protocol suite, Linux, Power User, SSH, TCP | Leave a Comment »

MultiBootUSB

Posted by jpluimers on 2020/05/07

Cool tool:

MultiBootUSB is a cross platform software written in python which allows you to install multiple live linux on a USB disk non destructively and option to uninstall distros. Try out the world’s first true cross platform multi boot live usb creator for free. Download Now!

Information and downloads on [WayBackMultiBootUSB.

There are actually a few repositories within [WayBack] mbusb (multibootusb) · GitHub of which one has a ruby implementation as well.

A more elaborate article is on [WayBack] How to Install Multiple Linux Distributions on One USB, but the site should get you going just fine.

Via: [WayBack] Multiple Linux distributions on one UBS stick. I just tried it with: * CloneZilla * Lubuntu * LiteLinux The tool they describe – MultiBootUSB – comes w… – Thomas Mueller (dummzeuch) – Google+

–jeroen

Posted in *nix, *nix-tools, Development, Hardware, Linux, Power User, Python, Software Development, USB | Leave a Comment »

Side by Side user scoped .NET Core installations on Linux with dotnet-install.sh – Scott Hanselman

Posted by jpluimers on 2020/04/28

For my link archive: [WayBack] Side by Side user scoped .NET Core installations on Linux with dotnet-install.sh – Scott Hanselman

Via [WayBack] DotNetKicks on Twitteru: „Side by Side user scoped .NET Core installations on Linux with  by @shanselman  #aspnet via @DotNetKicks“

–jeroen

Posted in .NET, .NET Core, .NET Core, .NET Standard, Development, Linux, Power User, Software Development | Leave a Comment »

How to install patterns in openSUSE and SUSE – TechRepublic

Posted by jpluimers on 2020/04/20

This was much easier than I hoped for: the zypper verbs search and install both support the --type pattern argument.

After that, the names for them are pattern names instead of the normal package names.

So for instance:

zypper search --type pattern
zypper install -type pattern kde kde_plasmaaa

Sources:

–jeroen

 

Posted in *nix, Linux, openSuSE, Power User, SuSE Linux, Tumbleweed | Leave a Comment »

sed double expression: match, replace in one line, overwrite file

Posted by jpluimers on 2020/04/15

A while ago, I needed to conditionally replace in files, so I used sed and a regular expression, though usually I dislike those.

However, since the system had a very basic install, there was not much choice.

Luckily back then, my Google foo returned these:

This allowed me to do a double expression (the first matches a pattern, the second performs the actual replacement within the matching lines).

In case my Google foo in the future fails:

## https://robots.thoughtbot.com/sed-102-replace-in-place
## -i causes no backup to be saved, but does in-place replacement
## since we run under git, we can always restore
## combined with a double expression (the first matches, the second executes) this is very powerful
sed -i -e '/#.*AVOID_DAILY_AUTOCOMMITS=.*$/s/^.//' /etc/etckeeper/etckeeper.conf && git diff | more

–jeroen

Posted in *nix, Development, etckeeper, Linux, Power User, RegEx, Software Development | Leave a Comment »

Some links on bind rndc

Posted by jpluimers on 2020/03/13

No, this is not a random number generator, according to the documentation, bind rndc is the name server control utility. Again very undescriptive; luckily the full name found elsewhere is Remote Name Daemon Control.

Some links for my archive as often there are no man-pages installed on systems with bind:

–jeroen

Posted in *nix, bind-named, Linux, Power User | Leave a Comment »

I love installers that can download and install in parallel threads….

Posted by jpluimers on 2020/02/04

[WayBack] I love installers that can download and install in parallel threads. Embarcadero and Zypper can learn from this. – Jeroen Wiert Pluimers – Google+

Most Linux distributions have package managers that can do this (apt and yum can), but OpenSuSE zypper (actually ZYpp) cannot even download packages in parallel:

Embarcadero is in the same state as zypper.

–jeroen

Posted in *nix, Development, openSuSE, Power User, Software Development, SuSE Linux, Tumbleweed | Leave a Comment »