GNU/Linux


Various problems with legacy SSH systems

Case 1

Unable to negotiate with 192.168.1.1 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1

We solved this problem using the following command:

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 [email protected];

Case 2

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 [email protected];
Unable to negotiate with 192.168.1.1 port 22: no matching host key type found. Their offer: ssh-rsa,ssh-dss

We solved this problem using the following command:

ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -oHostKeyAlgorithms=+ssh-dss [email protected];

How to Free Space from /var/log by Removing Old Log Files

Introduction

Managing disk space is a critical task for system administrators and users alike. In Linux systems, the /var/log directory can become a source of space consumption due to the accumulation of log files. In this post, we’ll explore a simple command to free up space by deleting old compressed log files and discuss its pros and cons.

The Command

The command find /var/log -type f -name "*.gz" -delete is a powerful way to clean up space in the /var/log directory. Here’s a breakdown of what this command does:

  • find /var/log: Searches in the /var/log directory.
  • -type f: Restricts the search to files.
  • -name "*.gz": Looks for files ending with .gz, which are typically compressed log files.
  • -delete: Deletes the files that match the search criteria.

Pros

  1. Efficient Space Management: This command quickly frees up disk space consumed by old, compressed log files, which is essential for the smooth functioning of the system.
  2. Automatable: The command can be automated through a cron job or a script, making regular maintenance easier.
  3. Selective Deletion: It specifically targets .gz files, which are usually older log files that have been compressed, thus keeping the most recent logs intact.

Cons

  1. Potential Data Loss: Important historical data in the log files could be lost if they are deleted without proper review.
  2. Lack of Control Over File Age: This command does not discriminate based on the age of the log files. It deletes all .gz files, regardless of how recently they were compressed.
  3. No Backup: The command executes a direct deletion without creating backups, which could be problematic if a file is deleted accidentally.

Best Practices

  • Review Files Before Deletion: Run the command without the -delete flag first to review which files will be deleted.
  • Implement Log Rotation: Set up log rotation to manage log files systematically, compressing and archiving older logs while deleting the oldest ones.
  • Backup Important Logs: Always keep a backup of important logs before running any deletion command.

Conclusion

While the command find /var/log -type f -name "*.gz" -delete is an effective way to free up space in the /var/log directory, it’s important to use it judiciously. Understanding its pros and cons helps in making informed decisions about log management in a Linux environment.


How to Create a WiFi Hotspot in Ubuntu 22.04

Creating a WiFi hotspot on Ubuntu 22.04 is a straightforward process that can be very useful for sharing your internet connection with other devices. Turning your Ubuntu machine into a WiFi access point is a handy solution, whether at home or in a setting where a traditional WiFi network isn’t available. Here’s a detailed guide on configuring WiFi Access Points using the network-manager snap.

Prerequisites

Before we begin, ensure that you have the following:

  • A computer running Ubuntu 22.04.
  • A wireless network interface on your Ubuntu device.
  • The network-manager snap installed on your system.

Step-by-Step Guide to Create a WiFi Hotspot

Open the Terminal: First, open your terminal. You can do this by pressing Ctrl + Alt + T or searching for ‘Terminal’ in your applications menu.

Identify Your WiFi Interface: You need to know the name of your WiFi network interface. You can find this by running the command nmcli device status. Look for the device under the “DEVICE” column that has “wifi” listed in the “TYPE” column.

Configure the WiFi Hotspot: Use the following command to set up your WiFi hotspot:php

nmcli d wifi hotspot ifname <wifi_iface> ssid <ssid> password <password>;

Replace <wifi_iface> with your WiFi interface name, <ssid> with your desired network name (SSID) and <password> with your chosen password. Remember, the password should be between 8-63 characters or 64 hexadecimal characters.

For example, if your WiFi interface is wlan0, your desired SSID is MyHotspot, and your password is MyStrongPassword123, the command will look like this:

Connection Verification: If the command is successful, network-manager will create a connection named ‘Hotspot <N>’, where <N> is a number. This indicates your hotspot is active.

Shared Internet Connection: The created hotspot offers a shared connection by default. This means any device connected to your hotspot should be able to access the internet if your Ubuntu device has internet access.

Connecting Devices: Search for available WiFi networks on your other devices (like smartphones or laptops). You should see the SSID you set (MyHotspot in our example). Connect to it using the password you configured.

Tips and Considerations

  • Ensure your device has a stable internet connection if you intend to share it via the hotspot.
  • Keep your hotspot secure by using a strong, unique password.
  • Remember that using your computer as a hotspot may impact its battery life more quickly if not plugged in.

Conclusion

Creating a WiFi hotspot on Ubuntu 22.04 is a useful feature, especially when you need to share your internet connection quickly and efficiently. Following these simple steps, you can turn your Ubuntu machine into a reliable WiFi access point for various devices.

ncmli device wifi hotspot [ifname ifname] [con-name name] [ssid SSID] [band {a | bg}] [channel channel] [password password]
   Create a Wi-Fi hotspot. The command creates a hotspot connection profile according to Wi-Fi device capabilities and activates it on the device. The hotspot is secured with WPA if device/driver supports that, otherwise WEP is used. Use connection down or device down to stop the hotspot.

   Parameters of the hotspot can be influenced by the optional parameters:

   ifname
       what Wi-Fi device is used.

   con-name
       name of the created hotspot connection profile.

   ssid
       SSID of the hotspot.

   band
       Wi-Fi band to use.

   channel
       Wi-Fi channel to use.

   password
       password to use for the created hotspot. If not provided, nmcli will generate a password. The password is either WPA pre-shared key or WEP key.

       Note that --show-secrets global option can be used to print the hotspot password.
       It is useful especially when the password was generated.

How to Run Three Instances of Signal on Ubuntu

Signal is a popular, privacy-focused messaging app. For various reasons, you might want to run multiple instances of Signal on your Ubuntu system. Here, we’ll guide you through the process of installing three different versions of Signal: the Snap package, the standard Debian-based installation, and the Signal Beta for Linux.

Prerequisites

  • Ubuntu OS (We recommend a recent version, like 20.04 or later)
  • Basic understanding of Linux terminal commands

1. Installing Signal from Snap

Snap is a package management system that makes it easy to install applications in Linux. Follow these steps to install Signal using Snap:

  1. Open Terminal: Use Ctrl+Alt+T to open the terminal.
  2. Install Signal: Enter the command: sudo snap install signal-desktop.
  3. Launch Signal: You can find Signal in your applications menu or launch it from the terminal with signal-desktop.

2. Installing Signal Using Linux (Debian-based) Install Instructions

For the second instance, we will use the Debian-based installation method (https://signal.org/download/):

  1. Add Signal’s Official Repository:
    • Open Terminal.
    • Enter:
      wget -O- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg;
      cat signal-desktop-keyring.gpg | sudo tee /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null;
    • Add the repository:
      echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' | sudo tee /etc/apt/sources.list.d/signal-xenial.list;
  2. Update and Install Signal:
    • Update package database: sudo apt update.
    • Install Signal: sudo apt install signal-desktop.
  3. Launch the Application: Find Signal in your application menu or type signal-desktop in the terminal.

3. Installing Signal Beta for Linux (Debian-based)

Finally, let’s install the Beta version (https://support.signal.org/hc/en-us/articles/360007318471-Signal-Beta):

  1. Add Signal Beta Repository:
    • Open Terminal.
    • Enter:
      wget -O- https://updates.signal.org/desktop/apt/keys.asc | gpg --dearmor > signal-desktop-keyring.gpg;
      cat signal-desktop-keyring.gpg | sudo tee -a /usr/share/keyrings/signal-desktop-keyring.gpg > /dev/null;
    • Add the Beta repository:
      echo 'deb [arch=amd64 signed-by=/usr/share/keyrings/signal-desktop-keyring.gpg] https://updates.signal.org/desktop/apt xenial main' | sudo tee -a /etc/apt/sources.list.d/signal-xenial.list
  2. Update and Install Signal Beta:
    • Update the system: sudo apt update.
    • Install Signal Beta: sudo apt install signal-desktop-beta.
  3. Launch Signal Beta: It should appear in your applications menu or can be started from the terminal with signal-desktop-beta.

Tips for Managing Multiple Instances

  • Different Profiles: Each instance of Signal will require a different phone number for registration.
  • System Resources: Running multiple instances can consume more system resources. Monitor your system’s performance.
  • Updates: Regularly check for updates to each version to ensure security and functionality.

Conclusion

With these steps, you should now have three different versions of Signal running on your Ubuntu system. This setup is ideal for separating personal, work, and testing environments within the same machine. Enjoy your enhanced and versatile messaging experience!