Kategoriarkiv: English

Setting up MSMTP for Protonmail

This is the config that worked for me.

First generate an SMTP token and a separate address for the system to use within Protonmail, otherwise this is not going to work without installing mail-bridge or something similar.

This will be special@domain.com

MSMTP Configuration file

Configuration file is /etc/msmtprc
File owner should be root:msmtp
File permissions 0660

defaults
tls on

account default
  host smtp.protonmail.ch
  port 587
  from special@domain.org
  set_from_header on
  auth on
  user special@domain.org
  password SMTP_TOKEN_GOES_HERE
  auth plain

Installation

Install the following components:

sudo apt install msmtp msmtp-mta mailutils bsd-mailx

Configuration

Edit the configuration file for mail /etc/mail.rc and add the following line to it:

set mta=/usr/bin/msmtp

You may also set up aliases if you like in the file /etc/aliases where you can add lines such as:

root: master@domain.org
caroline: caroline@example.com
defaul: admin@domain.org

Set netplan to use network-manager

Network manager has been working reasonably well in Ubuntu and other Debian derivatives for quite some time and then Canonical changes to netplan. This is causing some confusion and is clearly seen by many (myself included) as a step backwards.

The original configuration file residing in /etc/netplan/01-netcfg.yaml contains the following:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s31f6:
      dhcp4: yes

This leads to the conclusion that reversion to network-manager with its text based interface (nmtui) etc might not be so easy but actually it is. Change the configuration file in netplan to the following:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
# Set and change netplan renderer to NetworkManager GUI tool 
network:
  version: 2
  renderer: NetworkManager

When done don’t forget to apply the changes to netplan:

$ sudo netplan apply

This takes care of the problem and now you can re-install network-manager with whatever interface you want to use and handle all your network interfaces through that instead.

Standard Linux installation script V1.0

This script installs some stuff I pretty much always need. It can be invoked with -d for desktop configuration in Ubuntu as well as -t for adding documentation and text utilities I use often.

Oh and it will also install zsh as your default shell including oh-my-zsh and the ’afowler’ theme.

Can easily be adapted to anything really.

# First update the system
sudo apt -y update
sudo apt -y upgrade

# General tools that is good to have for all systems
sudo apt -y install build-essential emacs git htop atop tmux byobu \
     zsh borgbackup wget curl nmap net-tools traceroute mtr mosh \
     irssi mc mg vim rsync rclone

# Oh my zsh
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# Set the good theme
sed -i 's/robbyrussell/afowler/' ~/.zshrc

while getopts hdm arg; do
    case "${arg}" in
    h)
        echo "Usage: install [options]"
        echo
        echo "-d      Install standard desktop tools needed."
        echo "-t      Text, documentation and LaTeX tools"
        ;;
    d)
        # Only if we have a desktop, othrwise skip
        sudo apt -y install dconf-editor gnome-tweaks gparted flameshot
        gsettings set org.gnome.shell.extensions.dash-to-dock extend-height false 
        gsettings set org.gnome.shell.extensions.dash-to-dock dock-position BOTTOM
        ;;
    t)
        # Multimedia stuff (with desktop)
        sudo apt -y install gimp vlc inkscape texlive-all texstudio calibre sigil
        ;;
    *)
        echo "Unknown uptions, use -h for more information."
        ;;
    esac
done

After cloning a Ubuntu 22.04 server

Many things have changed from the oh so abundant 18.04 server and there are a few surprises that one needs to be aware of. One thing that has changed is that changing the MAC address no longer changes the ID when the server requests a new IP from a DHCP server.

This means that cloning a server into a new server they will start competing for the same IP address if they are on the same network so there are a few things you need to do before you deploy the new close.

Fix the IP address of the clone

  1. First release the DHCP address the machine has by issuing the command ”dhcpd -r” which should take care of this.
  2. Change the mac address, if you are using bridged network in particular there should not be two network interfaces on the same segment with the same MAC address. This is done in the virtual machine software.
  3. Change the machine-id of the clone. This is done by deleting the file /etc/machine-id and then running the script systemd-machine-id-setup which will create a new one.
  4. Optional: If you would like the system to change the network ID when you change mac address on the NIC then you need to change the following file(s) /etc/netplan/*.yaml and edit this to insert under each of the network interfaces you want to use MAC address as their ID ”dhcp-identifier: mac” then run sudo netplan apply.

Now shutdown the host, change the networking to whatever is needed (bridged most usually) and then restart the system and it should now be assigned a new IP address.

Fix the SSH keys of the clone

Next step is of course to change the cloes SSH keys which is done by deleting the keys in /etc/ssh by issuing the command ”rm /etc/ssh/ssh_host_*” which would delete all of them.

Then regenerate new keys from using the command ”dpkg-reconfigure openssh-server” which will generate all needed keys as if it was fresly installed.

Bevingade ord

Sleep resume in Ubuntu screws up mouse pad

I found that my Lenovo laptops did not always get the mousepad right when coming out of sleep or hibernate. After a bit of research I found that a modprobe remove and insert of the psmouse kernel module did the trick.

To automatize this you can insert a file in the systemd control structure to fix the problem yourself (if you are experiencing it). Below is a block of code. Save this to a file in /lib/systemd/system-sleep/touchpad

#!/bin/sh

PATH=/sbin:/usr/sbin:/bin:/usr/bin

case "$1" in
    pre)
    #code execution BEFORE sleeping/hibernating/suspending
    # unload touchpad driver
	/usr/sbin/modprobe -r psmouse
    ;;
    post)
    #code execution AFTER resuming
    # reload touchpad driver
	/usr/sbin/modprobe psmouse
    ;;
esac

exit 0